<?php
function xiangmu_create(){
	  //我们为这个页面设置标题
	 drupal_set_title('新增项目信息');
	 $page_content = l('查看待上会项目信息列表','daishanghuixiangmu/list') . '<br />'. '<br />';
	 $render_array = array(
	   '#markup' => $page_content, 
	 );
	 
	 $form = drupal_get_form('xiangmu_form');
	 $render_array['#markup'] .= drupal_render($form);
	 
	 return $render_array;
}

function xiangmu_form($form, &$form_state){
	drupal_add_css(drupal_get_path("module","xiangmuguanli")."/xiangmu_form.css");
	$form['tips'] = array(
	  '#prefix' =>'<div id="tips">',
	  '#markup' => t('<span class="form-required">*</span> 号为必填项。'),
	  '#suffix' =>'</div>',
	 );
	 $form['biaoti'] = array(
	  "#prefix" => "<h2><center>",
	  "#markup" =>"投决会项目概况表",
	  "#suffix" => "</center></h2><br>",
	   );
	 $form['jibenxinxi'] = array(
	  "#prefix" => "<table border=\"1\"><tr><td colspan=6><center><h4>",
	  "#markup" =>"基本信息",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['company_name'] = array(
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  "#prefix" => "<tr><th>公司名称</th><td colspan=3>",
	  "#suffix" => "</td>",
	   );
	 $form['locality'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>所属地区</th><td>",
	  "#suffix" => "</td></tr>",
	 );	 
	 $form['address'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>办公地址</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );
	 $form['zuce_money'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>注册资金</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['chenglishijian'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>成立时间</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['website'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>网址</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	 
	 $form['fadingdaibiao'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>法定代表人</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['yuangong_num'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>员工人数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['shifou_gaoxingqiye'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<th>是否高新技术企业</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	 
	 $form['qiye_contact'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>企业联系人</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['phone'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>电话</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['mobile'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>手机</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	  $form['mail'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>邮箱</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	   
	 //股东构成
	 $form['gudonggoucheng'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"股东构成",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['xuhao'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"序号",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"股东",
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"持股数",
	  "#suffix" => "</center></td>",
	 );
	 $form['bili'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"比例",
	  "#suffix" => "</center></td>",
	 );
	  $form['beizhu'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  "#markup" =>"备注",
	  "#suffix" => "</center></td>",
	 );
	   $form['xuhao1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"1",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu1'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"2",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu2'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"3",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu3'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"4",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu4'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"5",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu5'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"6",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['bili6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu6'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	 
	 $form['kongzhiren'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>实际控制人介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	 
	 //行业与市场
	 $form['hangye'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"行业与市场",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['field'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<tr><th>所属行业</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['market_amount'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>市场规模</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['xiangmujieduan'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>项目阶段</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	  $form['market_dinwei'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<tr><th>市场地位</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['hangyejieshao'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>行业介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['yewuchanpin'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>业务产品</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	 
	 $form['jishuzhuangkuang'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>技术状况</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['competitor'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>竞争对手</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['yuancailiao'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>原材料</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 //过往业绩及预测（万元）
	  $form['guowangyeji'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"过往业绩及预测（万元）",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['nianfen'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"年份",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"营业收入",
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净利润",
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"总资产",
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净资产",
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"利润率",
	  "#suffix" => "</center></td><tr>",
	 );
	   $form['nianfen1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"后年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	  $form['nianfen2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"明年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"今年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"去年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"大前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	 //融资与退出
	 $form['rongzi'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"融资与退出",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['shanglunrongzijiage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>上轮融资价格</th><td colspan=2>",
	  "#suffix" => "</td>",
	 );	    	
	  $form['qiye_gubenshu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>企业总股本数</th><td colspan=2>",
	  "#suffix" => "</td></tr>",
	 );	 

     $form['benlunrongzie'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>本轮总融资额</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['rangchugushu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>让出股数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['meigujiage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>每股价格</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 $form['xiangmuguzhi'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>项目估值</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['jinnianlirun'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>今年利润</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['touzihousiyinglv'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>投资后市盈率</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 $form['touzie'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>投资额</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['shougougushu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>收购股本数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['zhangu_percentage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>占股比例</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	  $form['rongziyongtu'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>融资用途</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	 $form['yujituichushijian'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>预计退出时间</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['yujituichufangshi'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>预计退出方式</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['siyinglvguji'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>市盈率估计</th><td>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	  $form['zonghuibaolv'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>总回报率</th><td>",
	  "#suffix" => "</td>",
	 );	    
	  $form['baozhangtiaokuan'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>保障条款</th><td colspan=3>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 //项目亮点
	  $form['liangdian'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"项目亮点",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['xiangmuliangdian1'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian2'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian3'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian4'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	//问题与风险
	 $form['wenti'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"问题与风险",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['wentifengxian1'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian2'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian3'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian4'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['qitashixiang'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"其他事项",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['others'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>其他事项</th><td colspan=5>",
	  "#suffix" => "</td></tr></table>",
	 );	
	 
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('确认'),
	  );
	  return $form;
}

function xiangmu_form_submit($form, &$form_state)
{
	$values = $form_state["values"];
	global  $user;
	$fund_id = 0;
	$query = "SELECT id, fund_id FROM " .
           "{fund_basic_information} where user_id = ?";
	 $queryResult = db_query($query, array($user->uid));
	 foreach($queryResult as $result){
	  	$fund_id = $result->fund_id;
	 }
	    $last_id = db_insert('xiangmu_info')
	  		->fields(array(
	  			 'user_id' => $user->uid,
	  		     'fund_id' => $fund_id, 
	   			 'tianbiao_timestamp' => $_SERVER['REQUEST_TIME'],
	   			 'state' => 0,
	   			 'company_name' =>  $values['company_name'],
	   			 'locality' => $values['locality'],
	   			 'address' => $values['address'],
	   			 'zuce_money' =>  $values['zuce_money'],
	   			 'chenglishijian' => $values['chenglishijian'],
	   			 'website' => $values['website'],
	   			 'fadingdaibiao' =>  $values['fadingdaibiao'],
	   			 'yuangong_num' => $values['yuangong_num'],
	   			 'shifou_gaoxingqiye' => $values['shifou_gaoxingqiye'],
	   			 'qiye_contact' =>  $values['qiye_contact'],
	   			 'phone' => $values['phone'],
	   			 'mobile' => $values['mobile'],
	   			 'mail' =>  $values['mail'],
	   			 'kongzhiren' => $values['kongzhiren'],
	   			 'field' => $values['field'],
	   			 'market_amount' =>  $values['market_amount'],
	   			 'xiangmujieduan' => $values['xiangmujieduan'],
	   			 'market_dinwei' => $values['market_dinwei'],
	   			 'hangyejieshao' =>  $values['hangyejieshao'],
	   			 'yewuchanpin' => $values['yewuchanpin'],
	   			 'jishuzhuangkuang' => $values['jishuzhuangkuang'],
	   			 'competitor' =>  $values['competitor'],
	   			 'yuancailiao' => $values['yuancailiao'],
	   			 'shanglunrongzijiage' => $values['shanglunrongzijiage'],
	   			 'qiye_gubenshu' =>  $values['qiye_gubenshu'],
	   			 'benlunrongzie' => $values['benlunrongzie'],
	   			 'rangchugushu' => $values['rangchugushu'],
	   			 'meigujiage' =>  $values['meigujiage'],
	   			 'xiangmuguzhi' => $values['xiangmuguzhi'],
	   			 'jinnianlirun' => $values['jinnianlirun'],
	   			 'touzihousiyinglv' =>  $values['touzihousiyinglv'],
	   			 'touzie' => $values['touzie'],
	   			 'shougougushu' => $values['shougougushu'],
	   			 'zhangu_percentage' =>  $values['zhangu_percentage'],
	   			 'rongziyongtu' => $values['rongziyongtu'],
	   			 
				 'yujituichushijian' =>  $values['yujituichushijian'],
	   			 'yujituichufangshi' => $values['yujituichufangshi'],
	   			 'siyinglvguji' => $values['siyinglvguji'],
	   			 'zonghuibaolv' =>  $values['zonghuibaolv'],
	   			 'baozhangtiaokuan' => $values['baozhangtiaokuan'],
	   			 'xiangmuliangdian1' => $values['xiangmuliangdian1'],
	   			 'xiangmuliangdian2' =>  $values['xiangmuliangdian2'],
	   			 'xiangmuliangdian3' => $values['xiangmuliangdian3'],
	   			 'xiangmuliangdian4' => $values['xiangmuliangdian4'],
	   			 'wentifengxian1' =>  $values['wentifengxian1'],
	   			 'wentifengxian2' => $values['wentifengxian2'],
	   			 'wentifengxian3' => $values['wentifengxian3'],
	   			 'wentifengxian4' =>  $values['wentifengxian4'],
	   			 'others' => $values['others'],	   			 
	  			))->execute();
			  if ($last_id!=NULL) {
			  	 for($i = 1; $i < 7;$i++){
			  	 	if($i == 1){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru1'],
				   			 'jinglirun' =>  $values['jinglirun1'],
				   			 'zongzichan' => $values['zongzichan1'],
				   			 'jingzichan' => $values['jingzichan1'],
				   			 'lirunlv' =>  $values['lirunlv1'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 2){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru2'],
				   			 'jinglirun' =>  $values['jinglirun2'],
				   			 'zongzichan' => $values['zongzichan2'],
				   			 'jingzichan' => $values['jingzichan2'],
				   			 'lirunlv' =>  $values['lirunlv2'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 3){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru3'],
				   			 'jinglirun' =>  $values['jinglirun3'],
				   			 'zongzichan' => $values['zongzichan3'],
				   			 'jingzichan' => $values['jingzichan3'],
				   			 'lirunlv' =>  $values['lirunlv3'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 4){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru4'],
				   			 'jinglirun' =>  $values['jinglirun4'],
				   			 'zongzichan' => $values['zongzichan4'],
				   			 'jingzichan' => $values['jingzichan4'],
				   			 'lirunlv' =>  $values['lirunlv4'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 5){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru5'],
				   			 'jinglirun' =>  $values['jinglirun5'],
				   			 'zongzichan' => $values['zongzichan5'],
				   			 'jingzichan' => $values['jingzichan5'],
				   			 'lirunlv' =>  $values['lirunlv5'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 6){
			  	 		db_insert('xiangmu_yeji_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'yingyeshouru' => $values['yingyeshouru6'],
				   			 'jinglirun' =>  $values['jinglirun6'],
				   			 'zongzichan' => $values['zongzichan6'],
				   			 'jingzichan' => $values['jingzichan6'],
				   			 'lirunlv' =>  $values['lirunlv6'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
			  	 }
			  	 	//添加股东构成
			  	 	
			  	 for($i = 1; $i < 7;$i++){
			  	 	if($i == 1){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'gudong' => $values['gudong1'],
				   			 'chigushu' =>  $values['chigushu1'],
				   			 'bili' => $values['bili1'],
				   			 'beizhu' => $values['beizhu1'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 2){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'gudong' => $values['gudong2'],
				   			 'chigushu' =>  $values['chigushu2'],
				   			 'bili' => $values['bili2'],
				   			 'beizhu' => $values['beizhu2'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 3){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'gudong' => $values['gudong3'],
				   			 'chigushu' =>  $values['chigushu3'],
				   			 'bili' => $values['bili3'],
				   			 'beizhu' => $values['beizhu3'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 4){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			  'gudong' => $values['gudong4'],
				   			 'chigushu' =>  $values['chigushu4'],
				   			 'bili' => $values['bili4'],
				   			 'beizhu' => $values['beizhu4'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 5){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			  'gudong' => $values['gudong5'],
				   			 'chigushu' =>  $values['chigushu5'],
				   			 'bili' => $values['bili5'],
				   			 'beizhu' => $values['beizhu5'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
					else if($i == 6){
			  	 		db_insert('xiangmu_gudong_info')
		  					->fields(array(
		  					 'xiangmu_id' => $last_id,
				   			 'gudong' => $values['gudong6'],
				   			 'chigushu' =>  $values['chigushu6'],
				   			 'bili' => $values['bili6'],
				   			 'beizhu' => $values['beizhu6'],
				   			 'state' =>  $i,
							))->execute();
			  	 	}
			  	 }
				
				 $form_state['redirect'] = 'xiangmu/view/'.$last_id;
			  } else {
			    drupal_set_message('抱歉，遇到问题，提交失败了', 'error');    
			  }	
}

//过会项目基金选择
function guohuixiangmu_fundlist_page() {
 $html = '';
 $header = array(
      array('data' => '基金名称', 'field' => 'registered_name', 'sort' => 'desc'),
      array('data' => '项目名称', 'field' => 'xiangmu_name', 'sort' => 'desc'),
      array('data' => '查看', 'field' => 'xiangmu_set'),
      );
  $query = db_select('fund_basic_information', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'registered_name',
      ));
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
  	 $query_xiangmu = db_select('xiangmu_info', 'n')
	      ->fields ('n', array (
	      'id',
	      'company_name',
	      ))
		  ->condition('fund_id',$node->id,'=')
		  ->condition('state',1,'=');  
	  $results_xiangmu = $query_xiangmu
	      ->execute();
	  foreach ($results_xiangmu as $xiangmu) {
		  $rows[] = array(
	      'data' => array(
	         l($node->registered_name, 'fund_basic_information/view/'. $node->id),
		     $xiangmu->company_name,
		     l('查看', 'xiangmu/list/'. $xiangmu->id),
	      )
	      );
	  }
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//过会项目列表
function guohuixiangmu_fundlist_perpage($fund_id) {
 $html = '';
 $html .= l("返回列表","guohuixiangmu/fundlist").'<br><br>';
 $header = array(
      array('data' => '公司名称', 'field' => 'company_name', 'sort' => 'desc'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '填表时间', 'field' => 'tianbiao_timestamp'),
      array('data' => '详情', 'field' => 'info_set'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      'tianbiao_timestamp',
      ))
	  ->condition('state',1,'=')
	  ->condition('fund_id',$fund_id,'=');
	  
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
		  $rows[] = array(
	      'data' => array(
	        $node->company_name,
	        $node->locality,
	        format_date($node->tianbiao_timestamp, 'custom', 'Y-m-d'),
	        l('查看', 'xiangmu/list/'.$node->id),
	      )
	      );
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有待上会项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//待上会基金选择
function daishanghuixiangmu_fundlist_page() {
 $html = '';
 $header = array(
      array('data' => '基金名称', 'field' => 'registered_name', 'sort' => 'desc'),
      array('data' => '项目名称', 'field' => 'xiangmu_name', 'sort' => 'desc'),
      array('data' => '查看', 'field' => 'xiangmu_set'),
      );
  $query = db_select('fund_basic_information', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'registered_name',
      ));
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
  	  $query_xiangmu = db_select('xiangmu_info', 'n')
	      ->fields ('n', array (
	      'id',
	      'company_name',
	      ))
		  ->condition('fund_id',$node->id,'=')
		  ->condition('state',0,'=');  
	  $results_xiangmu = $query_xiangmu
	      ->execute();
	  foreach ($results_xiangmu as $xiangmu) {
			  $rows[] = array(
		      'data' => array(
		        l($node->registered_name, 'fund_basic_information/view/'. $node->id),
		        $xiangmu->company_name,
		        l('查看', 'xiangmu/list/'. $xiangmu->id),
		      )
		      );
	   }
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//待上会项目列表
function daishanghuixiangmu_fundlist_perpage($fund_id) {
 $html = '';
 $html .= l("返回列表","daishanghuixiangmu/fundlist").'<br><br>';
 $header = array(
      array('data' => '公司名称', 'field' => 'company_name', 'sort' => 'desc'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '填表时间', 'field' => 'tianbiao_timestamp'),
      array('data' => '详情', 'field' => 'info_set'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      'tianbiao_timestamp',
      ))
	  ->condition('state',0,'=')
	  ->condition('fund_id',$fund_id,'=');
	  
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
		  $rows[] = array(
	      'data' => array(
	        $node->company_name,
	        $node->locality,
	        format_date($node->tianbiao_timestamp, 'custom', 'Y-m-d'),
	        l('查看', 'xiangmu/list/'.$node->id),
	      )
	      );
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有待上会项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//待上会项目列表
function daishanghuixiangmu_list_page() {
 $html = '';
 $html .= l("添加待上会项目","xiangmu/create").'<br><br>';
 global $user;
 $header = array(
      array('data' => '公司名称', 'field' => 'company_name', 'sort' => 'desc'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '填表时间', 'field' => 'tianbiao_timestamp'),
      array('data' => '详情', 'field' => 'info_set'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      'tianbiao_timestamp',
      ))
	  ->condition('state',0,'=')
	  ->condition('user_id',$user->uid,'=');
	  
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
		  $rows[] = array(
	      'data' => array(
	        $node->company_name,
	        $node->locality,
	        format_date($node->tianbiao_timestamp, 'custom', 'Y-m-d'),
	        l('查看', 'xiangmu/view/'.$node->id),
	      )
	      );
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有待上会项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//待上会项目列表
function guohuixiangmu_list_page() {
 $html = '';
 global $user;
 $html .= "<br><h3>已通过项目列表</h3><br>";
 $header = array(
      array('data' => '公司名称', 'field' => 'company_name', 'sort' => 'desc'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '填表时间', 'field' => 'tianbiao_timestamp'),
      array('data' => '详情', 'field' => 'info_set'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      'tianbiao_timestamp',
      ))
	  ->condition('state',1,'=')
	  ->condition('user_id',$user->uid,'=');
	  
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
		  $rows[] = array(
	      'data' => array(
	        $node->company_name,
	        $node->locality,
	        format_date($node->tianbiao_timestamp, 'custom', 'Y-m-d'),
	        l('查看', 'xiangmu/view/'.$node->id),
	      )
	      );
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有已通过项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
 $html .= "<br><h3>未通过项目列表</h3><br>";
 $header = array(
      array('data' => '公司名称', 'field' => 'company_name', 'sort' => 'desc'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '填表时间', 'field' => 'tianbiao_timestamp'),
      array('data' => '详情', 'field' => 'info_set'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      'tianbiao_timestamp',
      ))
	  ->condition('state',2,'=')
	  ->condition('user_id',$user->uid,'=');
	  
  $results = $query
      ->execute();

  $rows = array();
  foreach ($results as $node) {
		  $rows[] = array(
	      'data' => array(
	        $node->company_name,
	        $node->locality,
	        format_date($node->tianbiao_timestamp, 'custom', 'Y-m-d'),
	        l('查看', 'xiangmu/view/'.$node->id),
	      )
	      );
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有未通过项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}


function xiangmu_view_page($perid)
{
	$html = array("#markup" => "");
	$query = "SELECT id,user_id FROM " .
           "{xiangmu_info} where id = ?";
   $queryResult = db_query($query, array($perid));
   global $user;
   $ifempty =TRUE;
   foreach ($queryResult as $links ) {
	  if($links->id>0)
		  $ifempty = FALSE;
	  if($user->uid != $links->user_id)
	  	$ifempty = TRUE;
   }
   if($ifempty)
	 {
	 	 drupal_goto("daishanghuixiangmu/list");
	 }
	$view_form = drupal_get_form("xiangmu_view_form",$perid);
	$html["#markup"] .= l("返回列表","daishanghuixiangmu/list").'&nbsp;&nbsp;';
	$html["#markup"] .= l("编辑","xiangmu/edit/".$perid).'&nbsp;&nbsp;';
	$html["#markup"] .= drupal_render($view_form);
	return $html;
}

function xiangmu_view_form($form, &$form_state,$perid)
{
   drupal_add_css(drupal_get_path("module","xiangmuguanli")."/xiangmu_form.css");
   $query = "SELECT * FROM " .
           "{xiangmu_info} where id = ?";
   $queryResult = db_query($query, array($perid));
   
   $result_values = "";
   $yeji1="";
   $yeji2="";
   $yeji3="";
   $yeji4="";
   $yeji5="";
   $yeji6="";
   $gudong1="";
   $gudong2="";
   $gudong3="";
   $gudong4="";
   $gudong5="";
   $gudong6="";
   foreach ($queryResult as $result_values)
	{
		for($i = 1; $i < 7; $i++){
			$query_yeji = "SELECT * FROM " .
           		"{xiangmu_yeji_info} where xiangmu_id = ? and state =?";
   			$query_yeji_Result = db_query($query_yeji, array($perid,$i));
			foreach ($query_yeji_Result as $yeji_values){
				if($i  == 1)
					$yeji1 = $yeji_values;
				else if($i  == 2)
					$yeji2 = $yeji_values;
				else if($i  == 3)
					$yeji3 = $yeji_values;
				else if($i  == 4)
					$yeji4 = $yeji_values;
				else if($i  == 5)
					$yeji5 = $yeji_values;
				else if($i  == 6)
					$yeji6 = $yeji_values;
			}
		}
		for($i = 1; $i < 7; $i++){
			$query_gudong = "SELECT * FROM " .
           		"{xiangmu_gudong_info} where xiangmu_id = ? and state =?";
   			$query_gudong_Result = db_query($query_gudong, array($perid,$i));
			foreach ($query_gudong_Result as $gudong_values){
				if($i  == 1)
					$gudong1 = $gudong_values;
				else if($i  == 2)
					$gudong2 = $gudong_values;
				else if($i  == 3)
					$gudong3 = $gudong_values;
				else if($i  == 4)
					$gudong4 = $gudong_values;
				else if($i  == 5)
					$gudong5 = $gudong_values;
				else if($i  == 6)
					$gudong6 = $gudong_values;
			}
		}
	}
	 $form['biaoti'] = array(
	  "#prefix" => "<h2><center>",
	  "#markup" =>"投决会项目概况表",
	  "#suffix" => "</center></h2><br>",
	   );
	 $form['jibenxinxi'] = array(
	  "#prefix" => "<table border=\"1\"><tr><td colspan=6><center><h4>",
	  "#markup" =>"基本信息",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['company_name'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->company_name,
	  "#prefix" => "<tr><th>公司名称</th><td colspan=3>",
	  "#suffix" => "</td>",
	   );
	 $form['locality'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->locality,
	  "#prefix" => "<th>所属地区</th><td>",
	  "#suffix" => "</td></tr>",
	 );	 
	 $form['address'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->address,
	  "#prefix" => "<tr><th>办公地址</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );
	 $form['zuce_money'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->zuce_money,
	  "#prefix" => "<tr><th>注册资金</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['chenglishijian'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->chenglishijian,
	  "#prefix" => "<th>成立时间</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['website'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->website,
	  "#prefix" => "<th>网址</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	 
	 $form['fadingdaibiao'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->fadingdaibiao,
	  "#prefix" => "<tr><th>法定代表人</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['yuangong_num'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->yuangong_num,
	  "#prefix" => "<th>员工人数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	 $shifou_gaoxingqiye = "是";
	 if($result_values->shifou_gaoxingqiye == 0){
	 	$shifou_gaoxingqiye = "否";
	 }
	 
	  $form['shifou_gaoxingqiye'] = array(
	  '#type' => 'item',
	  "#markup" => $shifou_gaoxingqiye,
	  "#prefix" => "<th>是否高新技术企业</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	 
	 $form['qiye_contact'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->qiye_contact,
	  "#prefix" => "<tr><th>企业联系人</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['phone'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->phone,
	  "#prefix" => "<th>电话</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['mobile'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->mobile,
	  "#prefix" => "<th>手机</th><td>",
	  "#suffix" => "</td></tr>",
	 );	   
	  $form['mail'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->mail,
	  "#prefix" => "<tr><th>邮箱</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	   
	 //股东构成
	 $form['gudonggoucheng'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"股东构成",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	   
	 
	  $form['xuhao'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"序号",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"股东",
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"持股数",
	  "#suffix" => "</center></td>",
	 );
	 $form['bili'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"比例",
	  "#suffix" => "</center></td>",
	 );
	  $form['beizhu'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  "#markup" =>"备注",
	  "#suffix" => "</center></td>",
	 );
	   $form['xuhao1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"1",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong1->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong1->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong1->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu1'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong1->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"2",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong2->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong2->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong2->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu2'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong2->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"3",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong3->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong3->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong3->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu3'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong3->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"4",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong4->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong4->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong4->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu4'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong4->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"5",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong5->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu5'] = array(
	  "#prefix" => "<td ><center>",
	 '#type' => 'item',
	  "#markup" => $gudong5->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili5'] = array(
	  "#prefix" => "<td ><center>",
	 '#type' => 'item',
	  "#markup" => $gudong5->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu5'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong5->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"6",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong6->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong6->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $gudong6->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu6'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'item',
	  "#markup" => $gudong6->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	 
	 $form['kongzhiren'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->kongzhiren,
	  "#prefix" => "<tr><th>实际控制人介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	 
	 //行业与市场
	  $form['hangyeshichang'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"行业与市场",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['field'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->field,
	  "#prefix" => "<tr><th>所属行业</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['market_amount'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->market_amount,
	  "#prefix" => "<th>市场规模</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['xiangmujieduan'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmujieduan,
	  "#prefix" => "<th>项目阶段</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	  $form['market_dinwei'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->market_dinwei,
	  "#prefix" => "<tr><th>市场地位</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['hangyejieshao'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->hangyejieshao,
	  "#prefix" => "<tr><th>行业介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['yewuchanpin'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->yewuchanpin,
	  "#prefix" => "<tr><th>业务产品</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	 
	 $form['jishuzhuangkuang'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->jishuzhuangkuang,
	  "#prefix" => "<tr><th>技术状况</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['competitor'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->competitor,
	  "#prefix" => "<tr><th>竞争对手</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['yuancailiao'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->yuancailiao,
	  "#prefix" => "<tr><th>原材料</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 //过往业绩及预测（万元）
	 $form['guowangyeji'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"过往业绩及预测(万元)",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['nianfen'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"年份",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"营业收入",
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净利润",
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"总资产",
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净资产",
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"利润率",
	  "#suffix" => "</center></td><tr>",
	 );
	   $form['nianfen1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"后年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji1->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji1->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji1->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji1->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji1->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	  $form['nianfen2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"明年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji2->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji2->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji2->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji2->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji2->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"今年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji3->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji3->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji3->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji3->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji3->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"去年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji4->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji4->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji4->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji4->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji4->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji5->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji5->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji5->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji5->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji5->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"大前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji6->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji6->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji6->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji6->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'item',
	  "#markup" => $yeji6->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	 //融资与退出
	  $form['rongzituichu'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"融资与退出",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['shanglunrongzijiage'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->shanglunrongzijiage,
	  "#prefix" => "<tr><th>上轮融资价格</th><td colspan=2>",
	  "#suffix" => "</td>",
	 );	    	
	  $form['qiye_gubenshu'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->qiye_gubenshu,
	  "#prefix" => "<th>企业总股本数</th><td colspan=2>",
	  "#suffix" => "</td></tr>",
	 );	 

     $form['benlunrongzie'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->benlunrongzie,
	  "#prefix" => "<tr><th>本轮总融资额</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['rangchugushu'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->rangchugushu,
	  "#prefix" => "<th>让出股数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['meigujiage'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->meigujiage,
	  "#prefix" => "<th>每股价格</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 $form['xiangmuguzhi'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmuguzhi,
	  "#prefix" => "<tr><th>项目估值</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['jinnianlirun'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->jinnianlirun,
	  "#prefix" => "<th>今年利润</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['touzihousiyinglv'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->touzihousiyinglv,
	  "#prefix" => "<th>投资后市盈率</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 $form['touzie'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->touzie,
	  "#prefix" => "<tr><th>投资额</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['shougougushu'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->shougougushu,
	  "#prefix" => "<th>收购股本数</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['zhangu_percentage'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->zhangu_percentage,
	  "#prefix" => "<th>占股比例</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	  $form['rongziyongtu'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->rongziyongtu,
	  "#prefix" => "<tr><th>融资用途</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	 $form['yujituichushijian'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->yujituichushijian,
	  "#prefix" => "<tr><th>预计退出时间</th><td>",
	  "#suffix" => "</td>",
	 );	    
	 $form['yujituichufangshi'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->yujituichufangshi,
	  "#prefix" => "<th>预计退出方式</th><td>",
	  "#suffix" => "</td>",
	 );	   
	  $form['siyinglvguji'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->siyinglvguji,
	  "#prefix" => "<th>市盈率估计</th><td>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	  $form['zonghuibaolv'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->zonghuibaolv,
	  "#prefix" => "<tr><th>总回报率</th><td>",
	  "#suffix" => "</td>",
	 );	    
	  $form['baozhangtiaokuan'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->baozhangtiaokuan,
	  "#prefix" => "<th>保障条款</th><td colspan=3>",
	  "#suffix" => "</td></tr>",
	 );	  
	 
	 //项目亮点
	  $form['liangdian'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"项目亮点",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['xiangmuliangdian1'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmuliangdian1,
	  "#prefix" => "<tr><th>项目亮点1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian2'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmuliangdian2,
	  "#prefix" => "<tr><th>项目亮点2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian3'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmuliangdian3,
	  "#prefix" => "<tr><th>项目亮点3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['xiangmuliangdian4'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->xiangmuliangdian4,
	  "#prefix" => "<tr><th>项目亮点4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 
	//问题与风险
	 $form['fengxian'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"问题与风险",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['wentifengxian1'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->wentifengxian1,
	  "#prefix" => "<tr><th>问题风险1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian2'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->wentifengxian2,
	  "#prefix" => "<tr><th>问题风险2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian3'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->wentifengxian3,
	  "#prefix" => "<tr><th>问题风险3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 $form['wentifengxian4'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->wentifengxian4,
	  "#prefix" => "<tr><th>问题风险4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	 );	
	 //其他信息
	 $form['qita'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"其他事项",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['others'] = array(
	  '#type' => 'item',
	  "#markup" => $result_values->others,
	  "#prefix" => "<tr><th>其他事项</th><td colspan=5>",
	  "#suffix" => "</td></tr></table>",
	 );	
	 
	 return $form;
}

function xiangmu_per_page($perid)
{
	$html = array("#markup" => "");
	$query = "SELECT id,fund_id,state FROM " .
           "{xiangmu_info} where id = ?";
   $queryResult = db_query($query, array($perid));
   $ifempty =TRUE;
   $fund_id = 0;
   $state = 0;
   foreach ($queryResult as $links ) {
	  if($links->id>0)
		  $ifempty = FALSE;
	  $fund_id = $links->fund_id;
	  $state = $links->state;
   }
   if($ifempty)
	 {
	 	 drupal_goto("daishanghuixiangmu/list");
	 }
	$view_form = drupal_get_form("xiangmu_view_form",$perid);
	if($state == 0){
		$html["#markup"] .= l("返回列表","daishanghuixiangmu/fundlist/".$fund_id).'&nbsp;&nbsp;';
	}
	else{
		$html["#markup"] .= l("返回列表","guohuixiangmu/fundlist/".$fund_id).'&nbsp;&nbsp;';
	}
	$html["#markup"] .= drupal_render($view_form);
	return $html;
}

function xiangmu_edit_page($perid)
{
	$html = array("#markup" => "");
	$query = "SELECT id,user_id FROM " .
           "{xiangmu_info} where id = ?";
   $queryResult = db_query($query, array($perid));
   global $user;
   $ifempty =TRUE;
   foreach ($queryResult as $links ) {
	  if($links->id>0)
		  $ifempty = FALSE;
	  if($user->uid != $links->user_id)
	  	$ifempty = TRUE;
   }
   if($ifempty)
	 {
	 	 drupal_goto("daishanghuixiangmu/list");
	 }
	$view_form = drupal_get_form("xiangmu_edit_form",$perid);
	$html["#markup"] .= l("返回列表","daishanghuixiangmu/list").'&nbsp;&nbsp;';
	$html["#markup"] .= l("浏览","xiangmu/view/".$perid).'<br><br>';
	$html["#markup"] .= drupal_render($view_form);
	return $html;
}

function xiangmu_edit_form($form, &$form_state, $perid){
	drupal_add_css(drupal_get_path("module","xiangmuguanli")."/xiangmu_form.css");
   $query = "SELECT * FROM " .
           "{xiangmu_info} where id = ?";
   $queryResult = db_query($query, array($perid));
   
   $result_values = "";
   $yeji1="";
   $yeji2="";
   $yeji3="";
   $yeji4="";
   $yeji5="";
   $yeji6="";
   $gudong1="";
   $gudong2="";
   $gudong3="";
   $gudong4="";
   $gudong5="";
   $gudong6="";
   foreach ($queryResult as $result_values)
	{
		for($i = 1; $i < 7; $i++){
			$query_yeji = "SELECT * FROM " .
           		"{xiangmu_yeji_info} where xiangmu_id = ? and state =?";
   			$query_yeji_Result = db_query($query_yeji, array($perid,$i));
			foreach ($query_yeji_Result as $yeji_values){
				if($i  == 1)
					$yeji1 = $yeji_values;
				else if($i  == 2)
					$yeji2 = $yeji_values;
				else if($i  == 3)
					$yeji3 = $yeji_values;
				else if($i  == 4)
					$yeji4 = $yeji_values;
				else if($i  == 5)
					$yeji5 = $yeji_values;
				else if($i  == 6)
					$yeji6 = $yeji_values;
			}
		}
		for($i = 1; $i < 7; $i++){
			$query_gudong = "SELECT * FROM " .
           		"{xiangmu_gudong_info} where xiangmu_id = ? and state =?";
   			$query_gudong_Result = db_query($query_gudong, array($perid,$i));
			foreach ($query_gudong_Result as $gudong_values){
				if($i  == 1)
					$gudong1 = $gudong_values;
				else if($i  == 2)
					$gudong2 = $gudong_values;
				else if($i  == 3)
					$gudong3 = $gudong_values;
				else if($i  == 4)
					$gudong4 = $gudong_values;
				else if($i  == 5)
					$gudong5 = $gudong_values;
				else if($i  == 6)
					$gudong6 = $gudong_values;
			}
		}
	}
	
	
	
	$form['tips'] = array(
	  '#prefix' =>'<div id="tips">',
	  '#markup' => t('<span class="form-required">*</span> 号为必填项。'),
	  '#suffix' =>'</div>',
	 );
	 $form["perid"] = array(
	"#type" => "hidden",
	"#value" => $perid, 
	);
	 $form['biaoti'] = array(
	  "#prefix" => "<h2><center>",
	  "#markup" =>"投决会项目概况表",
	  "#suffix" => "</center></h2><br>",
	   );
	 $form['jibenxinxi'] = array(
	  "#prefix" => "<table border=\"1\"><tr><td colspan=6><center><h4>",
	  "#markup" =>"基本信息",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['company_name'] = array(
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  "#prefix" => "<tr><th>公司名称</th><td colspan=3>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->company_name,
	   );
	 $form['locality'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>所属地区</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->locality,
	 );	 
	 $form['address'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>办公地址</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->address,
	 );
	 $form['zuce_money'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>注册资金</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->zuce_money,
	 );	    
	 $form['chenglishijian'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>成立时间</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->chenglishijian,
	 );	   
	  $form['website'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>网址</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->website,
	 );	   
	 
	 $form['fadingdaibiao'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>法定代表人</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->fadingdaibiao,
	 );	    
	 $form['yuangong_num'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>员工人数</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->yuangong_num,
	 );	   
	  $form['shifou_gaoxingqiye'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<th>是否高新技术企业</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->shifou_gaoxingqiye,
	 );	   
	 
	 $form['qiye_contact'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>企业联系人</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->qiye_contact,
	 );	    
	 $form['phone'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>电话</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->phone,
	 );	   
	  $form['mobile'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>手机</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->mobile,
	 );	   
	  $form['mail'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>邮箱</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->mail,
	 );	   
	 //股东构成
	 $form['gudonggoucheng'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"股东构成",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['xuhao'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"序号",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"股东",
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"持股数",
	  "#suffix" => "</center></td>",
	 );
	 $form['bili'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"比例",
	  "#suffix" => "</center></td>",
	 );
	  $form['beizhu'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  "#markup" =>"备注",
	  "#suffix" => "</center></td>",
	 );
	   $form['xuhao1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"1",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong1->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong1->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong1->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu1'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong1->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"2",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong2->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong2->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong2->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu2'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong2->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"3",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong3->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong3->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong3->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu3'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong3->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"4",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong4->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong4->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong4->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu4'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong4->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"5",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong5->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu5'] = array(
	  "#prefix" => "<td ><center>",
	 '#type' => 'textfield',
	  "#default_value" => $gudong5->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili5'] = array(
	  "#prefix" => "<td ><center>",
	 '#type' => 'textfield',
	  "#default_value" => $gudong5->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu5'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong5->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	   $form['xuhao6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"6",
	  "#suffix" => "</center></td>",
	 );
	   $form['gudong6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong6->gudong,
	  "#suffix" => "</center></td>",
	 );
	 $form['chigushu6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong6->chigushu,
	  "#suffix" => "</center></td>",
	 );
	  $form['bili6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong6->bili,
	  "#suffix" => "</center></td>",
	 );
	 $form['beizhu6'] = array(
	  "#prefix" => "<td colspan=2><center>",
	  '#type' => 'textfield',
	  "#default_value" => $gudong6->beizhu,
	  "#suffix" => "</center></td><tr>",
	 );	 
	 $form['kongzhiren'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>实际控制人介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->kongzhiren,
	 );	 
	 //行业与市场
	 $form['hangye'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"行业与市场",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['field'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<tr><th>所属行业</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->field,
	 );	    
	 $form['market_amount'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>市场规模</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->market_amount,
	 );	   
	  $form['xiangmujieduan'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<th>项目阶段</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->xiangmujieduan,
	 );	  
	  $form['market_dinwei'] = array(
	  '#type' => 'textfield',
	  
	  "#prefix" => "<tr><th>市场地位</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->market_dinwei,
	 );	
	 $form['hangyejieshao'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>行业介绍</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->hangyejieshao,
	 );	
	 $form['yewuchanpin'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>业务产品</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->yewuchanpin,
	 );	 
	 $form['jishuzhuangkuang'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>技术状况</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->jishuzhuangkuang,
	 );	
	 $form['competitor'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>竞争对手</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->competitor,
	 );	
	 $form['yuancailiao'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>原材料</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->yuancailiao,
	 );	
	 //过往业绩及预测（万元）
	 $form['guowangyeji'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"过往业绩及预测（万元）",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['nianfen'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"年份",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"营业收入",
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净利润",
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"总资产",
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"净资产",
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv'] = array(
	  "#prefix" => "<td ><center>",
	  "#markup" =>"利润率",
	  "#suffix" => "</center></td><tr>",
	 );
	   $form['nianfen1'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"后年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji1->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji1->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji1->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji1->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv1'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji1->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	  $form['nianfen2'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"明年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji2->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji2->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji2->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji2->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv2'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji2->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen3'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"今年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji3->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji3->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji3->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji3->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv3'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji3->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen4'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"去年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji4->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji4->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji4->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji4->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv4'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji4->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen5'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji5->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji5->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji5->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji5->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv5'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji5->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	
	$form['nianfen6'] = array(
	  "#prefix" => "<tr><td ><center>",
	  "#markup" =>"大前年",
	  "#suffix" => "</center></td>",
	 );
	   $form['yingyeshouru6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji6->yingyeshouru,
	  "#suffix" => "</center></td>",
	 );
	 $form['jinglirun6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#markup" => $yeji6->jinglirun,
	  "#suffix" => "</center></td>",
	 );
	 $form['zongzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji6->zongzichan,
	  "#suffix" => "</center></td>",
	 );
	  $form['jingzichan6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji6->jingzichan,
	  "#suffix" => "</center></td>",
	 );
	 $form['lirunlv6'] = array(
	  "#prefix" => "<td ><center>",
	  '#type' => 'textfield',
	  "#default_value" => $yeji6->lirunlv,
	  "#suffix" => "</center></td><tr>",
	 );	 
	 //融资与退出
	  $form['rongzituichu'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"融资与退出",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['shanglunrongzijiage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>上轮融资价格</th><td colspan=2>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->shanglunrongzijiage,
	 );	    	
	  $form['qiye_gubenshu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>企业总股本数</th><td colspan=2>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->qiye_gubenshu,
	 );	 

     $form['benlunrongzie'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>本轮总融资额</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->benlunrongzie,
	 );	    
	 $form['rangchugushu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>让出股数</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->rangchugushu,
	 );	   
	  $form['meigujiage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>每股价格</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->meigujiage,
	 );	  
	 
	 $form['xiangmuguzhi'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>项目估值</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->xiangmuguzhi,
	 );	    
	 $form['jinnianlirun'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>今年利润</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->jinnianlirun,
	 );	   
	  $form['touzihousiyinglv'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>投资后市盈率</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->touzihousiyinglv,
	 );	  
	 
	 $form['touzie'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>投资额</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->touzie,
	 );	    
	 $form['shougougushu'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>收购股本数</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->shougougushu,
	 );	   
	  $form['zhangu_percentage'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>占股比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->zhangu_percentage,
	 );	  
	 
	  $form['rongziyongtu'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>融资用途</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->rongziyongtu,
	 );	
	 
	 $form['yujituichushijian'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>预计退出时间</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->yujituichushijian,
	 );	    
	 $form['yujituichufangshi'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>预计退出方式</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->yujituichufangshi,
	 );	   
	  $form['siyinglvguji'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>市盈率估计</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->siyinglvguji,
	 );	
	 
	  $form['zonghuibaolv'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<tr><th>总回报率</th><td>",
	  "#suffix" => "</td>",
	  "#default_value" => $result_values->zonghuibaolv,
	 );	    
	  $form['baozhangtiaokuan'] = array(
	  '#type' => 'textfield',

	  "#prefix" => "<th>保障条款</th><td colspan=3>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->baozhangtiaokuan,
	 );	  
	 
	 //项目亮点
	  $form['xiangmuliangdian'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"项目亮点",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	  $form['xiangmuliangdian1'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->xiangmuliangdian1,
	 );	
	 $form['xiangmuliangdian2'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->xiangmuliangdian2,
	 );	
	 $form['xiangmuliangdian3'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->xiangmuliangdian3,
	 );	
	 $form['xiangmuliangdian4'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>项目亮点4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->xiangmuliangdian4,
	 );	
	 
	//问题与风险
	  $form['wenti'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"问题与风险",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['wentifengxian1'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险1</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->wentifengxian1,
	 );	
	 $form['wentifengxian2'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险2</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->wentifengxian2,
	 );	
	 $form['wentifengxian3'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险3</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->wentifengxian3,
	 );	
	 $form['wentifengxian4'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>问题风险4</th><td colspan=5>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result_values->wentifengxian4,
	 );	
	 //其他事项
	  $form['qita'] = array(
	  "#prefix" => "<tr><td colspan=6><center><h4>",
	  "#markup" =>"其他事项",
	  "#suffix" => "</h4></center></td></tr>",
	 );
	 $form['others'] = array(
	  '#type' => 'textarea',

	  "#prefix" => "<tr><th>其他事项</th><td colspan=5><h4>",
	  "#suffix" => "</h4></td></tr></table>",
	  "#default_value" => $result_values->others,
	 );	
	 
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('确认'),
	  );
	  return $form;
}

function xiangmu_edit_form_submit($form, &$form_state)
{
	$values = $form_state["values"];
	db_update('xiangmu_info')
	  		->fields(array(
	   			 'company_name' =>  $values['company_name'],
	   			 'locality' => $values['locality'],
	   			 'address' => $values['address'],
	   			 'zuce_money' =>  $values['zuce_money'],
	   			 'chenglishijian' => $values['chenglishijian'],
	   			 'website' => $values['website'],
	   			 'fadingdaibiao' =>  $values['fadingdaibiao'],
	   			 'yuangong_num' => $values['yuangong_num'],
	   			 'shifou_gaoxingqiye' => $values['shifou_gaoxingqiye'],
	   			 'qiye_contact' =>  $values['qiye_contact'],
	   			 'phone' => $values['phone'],
	   			 'mobile' => $values['mobile'],
	   			 'mail' =>  $values['mail'],
	   			 'kongzhiren' => $values['kongzhiren'],
	   			 'field' => $values['field'],
	   			 'market_amount' =>  $values['market_amount'],
	   			 'xiangmujieduan' => $values['xiangmujieduan'],
	   			 'market_dinwei' => $values['market_dinwei'],
	   			 'hangyejieshao' =>  $values['hangyejieshao'],
	   			 'yewuchanpin' => $values['yewuchanpin'],
	   			 'jishuzhuangkuang' => $values['jishuzhuangkuang'],
	   			 'competitor' =>  $values['competitor'],
	   			 'yuancailiao' => $values['yuancailiao'],
	   			 'shanglunrongzijiage' => $values['shanglunrongzijiage'],
	   			 'qiye_gubenshu' =>  $values['qiye_gubenshu'],
	   			 'benlunrongzie' => $values['benlunrongzie'],
	   			 'rangchugushu' => $values['rangchugushu'],
	   			 'meigujiage' =>  $values['meigujiage'],
	   			 'xiangmuguzhi' => $values['xiangmuguzhi'],
	   			 'jinnianlirun' => $values['jinnianlirun'],
	   			 'touzihousiyinglv' =>  $values['touzihousiyinglv'],
	   			 'touzie' => $values['touzie'],
	   			 'shougougushu' => $values['shougougushu'],
	   			 'zhangu_percentage' =>  $values['zhangu_percentage'],
	   			 'rongziyongtu' => $values['rongziyongtu'],
	   			 
				 'yujituichushijian' =>  $values['yujituichushijian'],
	   			 'yujituichufangshi' => $values['yujituichufangshi'],
	   			 'siyinglvguji' => $values['siyinglvguji'],
	   			 'zonghuibaolv' =>  $values['zonghuibaolv'],
	   			 'baozhangtiaokuan' => $values['baozhangtiaokuan'],
	   			 'xiangmuliangdian1' => $values['xiangmuliangdian1'],
	   			 'xiangmuliangdian2' =>  $values['xiangmuliangdian2'],
	   			 'xiangmuliangdian3' => $values['xiangmuliangdian3'],
	   			 'xiangmuliangdian4' => $values['xiangmuliangdian4'],
	   			 'wentifengxian1' =>  $values['wentifengxian1'],
	   			 'wentifengxian2' => $values['wentifengxian2'],
	   			 'wentifengxian3' => $values['wentifengxian3'],
	   			 'wentifengxian4' =>  $values['wentifengxian4'],
	   			 'others' => $values['others'],	   			 
	  			))
	  			->condition('id', $values["perid"])
	  			->execute();
			for($i = 1; $i < 7;$i++){
			  	 	if($i == 1){
			  	 		db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru1'],
				   			 'jinglirun' =>  $values['jinglirun1'],
				   			 'zongzichan' => $values['zongzichan1'],
				   			 'jingzichan' => $values['jingzichan1'],
				   			 'lirunlv' =>  $values['lirunlv1'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 2){
			  	 			db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru2'],
				   			 'jinglirun' =>  $values['jinglirun2'],
				   			 'zongzichan' => $values['zongzichan2'],
				   			 'jingzichan' => $values['jingzichan2'],
				   			 'lirunlv' =>  $values['lirunlv2'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 3){
			  	 			db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru3'],
				   			 'jinglirun' =>  $values['jinglirun3'],
				   			 'zongzichan' => $values['zongzichan3'],
				   			 'jingzichan' => $values['jingzichan3'],
				   			 'lirunlv' =>  $values['lirunlv3'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 4){
			  	 			db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru4'],
				   			 'jinglirun' =>  $values['jinglirun4'],
				   			 'zongzichan' => $values['zongzichan4'],
				   			 'jingzichan' => $values['jingzichan4'],
				   			 'lirunlv' =>  $values['lirunlv4'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 5){
			  	 			db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru5'],
				   			 'jinglirun' =>  $values['jinglirun5'],
				   			 'zongzichan' => $values['zongzichan5'],
				   			 'jingzichan' => $values['jingzichan5'],
				   			 'lirunlv' =>  $values['lirunlv5'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 6){
			  	 			db_update('xiangmu_yeji_info')
		  					->fields(array(
				   			 'yingyeshouru' => $values['yingyeshouru6'],
				   			 'jinglirun' =>  $values['jinglirun6'],
				   			 'zongzichan' => $values['zongzichan6'],
				   			 'jingzichan' => $values['jingzichan6'],
				   			 'lirunlv' =>  $values['lirunlv6'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
    		}  
			for($i = 1; $i < 7;$i++){
			  	 	if($i == 1){
			  	 		db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			 'gudong' => $values['gudong1'],
				   			 'chigushu' =>  $values['chigushu1'],
				   			 'bili' => $values['bili1'],
				   			 'beizhu' => $values['beizhu1'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 2){
			  	 			db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			'gudong' => $values['gudong2'],
				   			 'chigushu' =>  $values['chigushu2'],
				   			 'bili' => $values['bili2'],
				   			 'beizhu' => $values['beizhu2'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 3){
			  	 			db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			 'gudong' => $values['gudong3'],
				   			 'chigushu' =>  $values['chigushu3'],
				   			 'bili' => $values['bili3'],
				   			 'beizhu' => $values['beizhu3'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 4){
			  	 			db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			'gudong' => $values['gudong4'],
				   			 'chigushu' =>  $values['chigushu4'],
				   			 'bili' => $values['bili4'],
				   			 'beizhu' => $values['beizhu4'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 5){
			  	 			db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			 'gudong' => $values['gudong5'],
				   			 'chigushu' =>  $values['chigushu5'],
				   			 'bili' => $values['bili5'],
				   			 'beizhu' => $values['beizhu5'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
					else if($i == 6){
			  	 			db_update('xiangmu_gudong_info')
		  					->fields(array(
				   			 'gudong' => $values['gudong6'],
				   			 'chigushu' =>  $values['chigushu6'],
				   			 'bili' => $values['bili6'],
				   			 'beizhu' => $values['beizhu6'],
							))
							->condition('xiangmu_id', $values["perid"])
							->condition('state',$i)
							->execute();
			  	 	}
			}
	$form_state['redirect'] = 'xiangmu/view/'.$values["perid"];
			
}

//////////////////////
//投决会信息相关
//////////////////////
//投决会项目选择
function toujuehui_xiangmu_list_page() {
 $html = '';
 $header = array(
       array('data' => '基金名称'),
       array('data' => '项目名称'),
       array('data' => '符合性审查信息'),
       array('data' => '符合性审查结果'),
       array('data' => '投决会时间'),
       array('data' => '查看投决会信息'),
       array('data' => '投决会结果'),
      );
  $query = db_select('fund_basic_information', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'registered_name',
      ));
  $results = $query
      ->execute();
	
  $rows = array();
  foreach ($results as $node) {
  		  $query_xiangmu = db_select('xiangmu_info', 'n')
		      ->fields ('n', array (
		      'id',
		      'company_name',
		      ))
			  ->condition('fund_id',$node->id,'=');  
		  $results_xiangmu = $query_xiangmu
		      ->execute();
		  
		  
		  foreach ($results_xiangmu as $xiangmu) {
		   	   $toujuehuiid = 0;
			   $huiyi_time = "";
			   $result = 0;
			   $toujuehui_link = "";
			   $toujue_result = "未投决";
			   $fuhe_panduan_result = "未审查";
			   $fuhe_panduan_link = l('新建', 'xiangmu_fuhe_panduan/create/'.$xiangmu->id);
			   
			  	$query = "SELECT * FROM " .
	           "{xiangmu_toujuehui} where xiangmu_id = ?";
			   $queryResult = db_query($query, array($xiangmu->id));
				foreach ($queryResult as $result_values)
				{
				   $toujuehuiid = $result_values->id;
				   $huiyi_time = $result_values->huiyi_time;		  
				   if($result_values->result == 0)
				   {
				   		$toujue_result = "未通过";
				   }
				   else{
				   		$toujue_result = "已通过";
				   }
				   $toujuehui_link = l('查看', 'xiangmu_toujuehui/view/'.$toujuehuiid);
				}
				
				$query = "SELECT panduan_final FROM " .
	           "{xiangmu_fuhe_panduan} where xiangmu_id = ?";
			   $queryResult = db_query($query, array($xiangmu->id));
				foreach ($queryResult as $result_values)
				{  
				   if($result_values->panduan_final == 0)
				   {
				   		$fuhe_panduan_result = "未通过";
				   }
				   else{
				   		$fuhe_panduan_result = "已通过";
				   }
				   $fuhe_panduan_link = l('编辑', 'xiangmu_fuhe_panduan/create/'.$xiangmu->id);
				}
				
			  	$rows[] = array(
			      'data' => array(
			        l($node->registered_name, 'fund_basic_information/view/'. $node->id),
			        l($xiangmu->company_name, 'xiangmu/list/'. $xiangmu->id),
			        $fuhe_panduan_link,
			        $fuhe_panduan_result,
			        $huiyi_time,
			        $toujuehui_link,
			        $toujue_result,
			      )
		      	);
		  }
		  
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

//投决会项目选择
function toujuehui_manage_list_page() {
 $html = '';
 global $user;
 $header = array(
 	   array('data' => '序号', 'sort' => 'desc'),
       array('data' => '项目名称'),
       array('data' => '符合性审查信息'),
       array('data' => '符合性审查结果'),
       array('data' => '投决会时间'),
       array('data' => '查看投决会信息'),
       array('data' => '投决会结果'),
      );
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(15)//10 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      ))
	   ->condition('user_id',$user->uid,'=');
  $results = $query
      ->execute();
  $num = 0;
  $rows = array();
  foreach ($results as $node) {
		  
		   $toujuehuiid = 0;
		   $huiyi_time = "";
		   $result = 0;
		   $toujuehui_link = l('新建', 'xiangmu_toujuehui/create/'.$node->id);
		   $toujue_result = "未投决";
		   $num += 1;
		   $fuhe_panduan_result = "未审查";
		   $fuhe_panduan_link = "";
		   	$query = "SELECT * FROM " .
           "{xiangmu_toujuehui} where xiangmu_id = ?";
		   $queryResult = db_query($query, array($node->id));
		   foreach ($queryResult as $result_values)
			{
			   $toujuehuiid = $result_values->id;
			   $huiyi_time = $result_values->huiyi_time;		  
			   if($result_values->result == 0)
			   {
			   		$toujue_result = "未通过";
			   }
			   else{
			   		$toujue_result = "已通过";
			   }
			   $toujuehui_link = l('编辑', 'xiangmu_toujuehui/create/'.$node->id);
			}
			$query = "SELECT panduan_final FROM " .
	           "{xiangmu_fuhe_panduan} where xiangmu_id = ?";
			   $queryResult = db_query($query, array($node->id));
				foreach ($queryResult as $result_values)
				{	  
				   if($result_values->panduan_final == 0)
				   {
				   		$toujue_result = "未通过";
				   }
				   else{
				   		$toujue_result = "已通过";
				   }
				   $toujuehui_link = l('浏览', 'xiangmu_fuhe_panduan/view/'.$node->id);
				}
				
		  	$rows[] = array(
		      'data' => array(
				$num,
		        l($node->company_name, 'xiangmu/view/'. $node->id),
		        $fuhe_panduan_link,
		        $fuhe_panduan_result,

		        $huiyi_time,
		        $toujuehui_link,
		        $toujue_result,
		      )
	      	);
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  return ($html); 
}

function toujuehui_create($xiangmu_id){
	  //我们为这个页面设置标题
	 drupal_set_title('新增投决会信息');
	 $page_content = l('返回列表','toujuehui_manage/list') . '<br />'. '<br />';
	 $render_array = array(
	   '#markup' => $page_content, 
	 );
	 $query = "SELECT user_id FROM " .
           "{xiangmu_info} where id = ?";
	 $queryResult = db_query($query, array($xiangmu_id));
	 foreach ($queryResult as $result_values)
	 {
	 	global $user;
	 	if($result_values->user_id != $user->uid)
		{
			drupal_goto('toujuehui_manage/list');
		}
	 }
	 $form = drupal_get_form('toujuehui_form',$xiangmu_id);
	 $render_array['#markup'] .= drupal_render($form);
	 
	 return $render_array;
}

function toujuehui_form($form, &$form_state,$xiangmu_id){
	
	$query = "SELECT * FROM " .
           "{xiangmu_toujuehui} where xiangmu_id = ?";
   $queryResult = db_query($query, array($xiangmu_id));
   $toujuehuiid = 0;
   $huiyi_time = "";
   $huiyi_address = "";
   $huiyi_people = "";
   $huiyi_content = "";
   $huiyi_piaoshu = "";
   $result = 0;
   $remark = "";
   
	foreach ($queryResult as $result_values)
	{
	   $toujuehuiid = $result_values->id;
	   $huiyi_time = $result_values->huiyi_time;
	   $huiyi_address = $result_values->huiyi_address;
	   $huiyi_people = $result_values->huiyi_people;
	   $huiyi_content = $result_values->huiyi_content;
	   $huiyi_piaoshu = $result_values->huiyi_piaoshu;
	   $result = $result_values->result;
	   $remark = $result_values->remark;
	}
	$form['tips'] = array(
	  '#prefix' =>'<div id="tips">',
	  '#markup' => t('<span class="form-required">*</span> 号为必填项。'),
	  '#suffix' =>'</div>',
	 );
	 $form["perid"] = array(
		"#type" => "hidden",
		"#value" => $xiangmu_id, 
	);
	 $form["toujuehuiid"] = array(
		"#type" => "hidden",
		"#value" => $toujuehuiid, 
	);
	 $form['huiyi_time'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<table border=\"1\" width=\"500px\"><tr><th>会议时间</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $huiyi_time,
	   );
	 $form['huiyi_address'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>会议地点</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $huiyi_address,
	   );
	 $form['huiyi_people'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>参加人员</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $huiyi_people,
	   );
	 $form['huiyi_content'] = array(
	  '#type' => 'textarea',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>主要讨论点</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $huiyi_content,
	   );
	 $form['huiyi_piaoshu'] = array(
	  '#type' => 'textarea',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>投决会票数</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $huiyi_piaoshu,
	   );
	 $form['result'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>是否通过</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $result,
	 );	  
	  $form['remark'] = array(
	  '#type' => 'textarea',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>备注</th><td>",
	  "#suffix" => "</td></tr></table>",
	  "#default_value" => $remark,
	   );
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('确认'),
	  );
	  return $form;
}

function toujuehui_form_submit($form, &$form_state)
{
	$values = $form_state["values"];
	 $query = "SELECT fund_id FROM " .
           "{xiangmu_info} where id = ?";
	 $queryResult = db_query($query, array($values['perid']));
	 $fund_id = 0;
	 foreach ($queryResult as $result_values)
	 {
		$fund_id = $result_values->fund_id;
	 }
	 $state = 1;
	 if($values['result'] == 0){
	 	$state = 2;
	 }
	 db_update('xiangmu_info')
	 	->fields(array(
	   		'state' =>  $state,
	   		))
		->condition('id', $fund_id)
	  	->execute();	
	if($values["toujuehuiid"]>0){
		db_update('xiangmu_toujuehui')
	  		->fields(array(
	   			 'huiyi_time' =>  $values['huiyi_time'],
	   			 'huiyi_address' => $values['huiyi_address'],
	   			 'huiyi_people' => $values['huiyi_people'],
	   			 'huiyi_content' =>  $values['huiyi_content'],
	   			 'huiyi_piaoshu' => $values['huiyi_piaoshu'],
	   			 'result' => $values['result'],
	   			 'remark' =>  $values['remark'],	 
	  			))
	  			->condition('id', $values["toujuehuiid"])
	  			->execute();
	   $form_state['redirect'] = 'toujuehui_manage/list';
	}		
	else{
		global $user;
		$lastid = db_insert('xiangmu_toujuehui')
	  		->fields(array(
	  			 'user_id' => $user->uid,
	  		     'xiangmu_id' =>$values['perid'],
	   			 'huiyi_time' =>  $values['huiyi_time'],
	   			 'huiyi_address' => $values['huiyi_address'],
	   			 'huiyi_people' => $values['huiyi_people'],
	   			 'huiyi_content' =>  $values['huiyi_content'],
	   			 'huiyi_piaoshu' => $values['huiyi_piaoshu'],
	   			 'result' => $values['result'],
	   			 'remark' =>  $values['remark'],			 
	  			))->execute();
		  if ($lastid!=NULL) {
				 $form_state['redirect'] = 'toujuehui_manage/list';
			  } else {
			    drupal_set_message('抱歉，遇到问题，提交失败了', 'error');    
			  }	
		
	}  
			
}

function toujuehui_view_page($perid)
{
	$html = array("#markup" => "");
	$html["#markup"] .= l("返回列表","toujuehui_xiangmu/list").'<br><br>';
	$query = "SELECT id,user_id FROM " .
           "{xiangmu_toujuehui} where id = ?";
   $queryResult = db_query($query, array($perid));
   global $user;
   $ifempty =TRUE;
   foreach ($queryResult as $links ) {
	  if($links->id>0)
		  $ifempty = FALSE;
   }
   if($ifempty)
	 {
	 	 $html["#markup"] .= "尚未填写该项目的投决会信息！";
	 }
   else{
   		$view_form = drupal_get_form("toujuehui_view_form",$perid);
		$html["#markup"] .= drupal_render($view_form);
   }
	return $html;
}

function toujuehui_view_form($form, &$form_state,$perid){
	$query = "SELECT * FROM " .
           "{xiangmu_toujuehui} where id = ?";
   $queryResult = db_query($query, array($perid));
   $xiangmu = 0;
   $toujuehuiid = 0;
   $huiyi_time = "";
   $huiyi_address = "";
   $huiyi_people = "";
   $huiyi_content = "";
   $huiyi_piaoshu = "";
   $result = 0;
   $remark = "";
   
	foreach ($queryResult as $result_values)
	{
	   $toujuehuiid = $result_values->id;
	   $huiyi_time = $result_values->huiyi_time;
	   $huiyi_address = $result_values->huiyi_address;
	   $huiyi_people = $result_values->huiyi_people;
	   $huiyi_content = $result_values->huiyi_content;
	   $huiyi_piaoshu = $result_values->huiyi_piaoshu;
	   $result = $result_values->result;
	   $remark = $result_values->remark;
	}
	 $form['huiyi_time'] = array(
	  '#type' => 'item',
	  "#markup" => $huiyi_time,
	  "#prefix" => "<table border=\"1\"><tr><th>会议时间</th><td width=\"80%\">",
	  "#suffix" => "</td></tr>",
	   );
	 $form['huiyi_address'] = array(
	  '#type' => 'item',
	  "#markup" => $huiyi_address,
	  "#prefix" => "<tr><th>会议地点</th><td>",
	  "#suffix" => "</td></tr>",
	   );
	 $form['huiyi_people'] = array(
	   '#type' => 'item',
	  "#markup" => $huiyi_people,
	  "#prefix" => "<tr><th>参加人员</th><td>",
	  "#suffix" => "</td></tr>",
	   );
	 $form['huiyi_content'] = array(
	   '#type' => 'item',
	  "#markup" => $huiyi_content,
	  "#prefix" => "<tr><th>主要讨论点</th><td>",
	  "#suffix" => "</td></tr>",
	   );
	 $form['huiyi_piaoshu'] = array(
	   '#type' => 'item',
	  "#markup" => $huiyi_piaoshu,
	  "#prefix" => "<tr><th>投决会票数</th><td>",
	  "#suffix" => "</td></tr>",
	   );
	 $form['result'] = array(
	   '#type' => 'checkbox',
	  "#default_value" => $result,
	  "#prefix" => "<tr><th>是否通过</th><td>",
	  "#suffix" => "</td></tr>",
	 );	  
	  $form['remark'] = array(
	  '#type' => 'item',
	  "#markup" => $remark,
	  "#prefix" => "<tr><th>备注</th><td>",
	  "#suffix" => "</td></tr></table>",
	   );
	  return $form;
}

//符合性审查
function xiangmu_fuhe_panduan_create($xiangmu_id){
	  //我们为这个页面设置标题
	 drupal_set_title('新增符合性审查信息');
	 $page_content = l('返回列表','toujuehui_xiangmu/list') . '<br />'. '<br />';
	 $render_array = array(
	   '#markup' => $page_content, 
	 );
	 $form = drupal_get_form('xiangmu_fuhe_panduan_form',$xiangmu_id);
	 $render_array['#markup'] .= drupal_render($form);
	 
	 return $render_array;
}

function xiangmu_fuhe_panduan_form($form, &$form_state,$xiangmu_id){
	
	$query = "SELECT * FROM " .
           "{xiangmu_fuhe_panduan} where xiangmu_id = ?";
   $queryResult = db_query($query, array($xiangmu_id));
   $fuhe_panduanid = 0;
   $jieduan = "";
   $bili_jieduan1 = "";
   $bili_jieduan2 = "";
   $bili_jieduan3 = "";
   $panduan_jieduan = 0;
   $bili_diyu1 = "";
   $bili_diyu2 = "";
   $bili_diyu3 = "";
   $bili_diyu4 = "";
   $bili_diyu5 = "";
   $panduan_diyu = 0;
   $lingyu = "";
   $bili_lingyu1 = "";
   $bili_lingyu2 = "";
   $bili_lingyu3 = "";
   $bili_lingyu4 = "";
   $panduan_lingyu = 0;
   $bili_danxiangmu1 = "";
   $bili_danxiangmu2 = "";
   $panduan_danxiangmu = 0;
   $panduan_fuhexing1 = 0;
   $panduan_11 = 0;
   $panduan_12 = 0;
   $panduan_13 = 0;
   $panduan_14 = 0;
   $panduan_15 = 0;
   $panduan_21 = 0;
   $panduan_22 = 0;
   $panduan_23 = 0;
   $panduan_24 = 0;
   $panduan_25 = 0;
   $panduan_26 = 0;
   $panduan_27 = 0;
   $panduan_28 = 0;
   $panduan_fuhexing2 = 0;
   $panduan_final = 0;
   $shenheren = "";
   $shenheshijian = "";
   
	foreach ($queryResult as $result_values)
	{
	    $fuhe_panduanid = $result_values->id;
	   $jieduan = $result_values->jieduan;
	   $bili_jieduan1 = $result_values->bili_jieduan1;
	   $bili_jieduan2 = $result_values->bili_jieduan2;
	   $bili_jieduan3 = $result_values->bili_jieduan3;
	   $panduan_jieduan = $result_values->panduan_jieduan;
	   $bili_diyu1 = $result_values->bili_diyu1;
	   $bili_diyu2 = $result_values->bili_diyu2;
	   $bili_diyu3 = $result_values->bili_diyu3;
	   $bili_diyu4 = $result_values->bili_diyu4;
	   $bili_diyu5 = $result_values->bili_diyu5;
	   $panduan_diyu = $result_values->panduan_diyu;
	   $lingyu = $result_values->lingyu;
	   $bili_lingyu1 = $result_values->bili_lingyu1;
	   $bili_lingyu2 = $result_values->bili_lingyu2;
	   $bili_lingyu3 = $result_values->bili_lingyu3;
	   $bili_lingyu4 = $result_values->bili_lingyu4;
	   $panduan_lingyu = $result_values->panduan_lingyu;
	   $bili_danxiangmu1 = $result_values->bili_danxiangmu1;
	   $bili_danxiangmu2 = $result_values->bili_danxiangmu2;
	   $panduan_danxiangmu = $result_values->panduan_danxiangmu;
	   $panduan_fuhexing1 = $result_values->panduan_fuhexing1;
	   $panduan_11 = $result_values->panduan_11;
	   $panduan_12 = $result_values->panduan_12;
	   $panduan_13 = $result_values->panduan_13;
	   $panduan_14 = $result_values->panduan_14;
	   $panduan_15 = $result_values->panduan_15;
	   $panduan_21 = $result_values->panduan_21;
	   $panduan_22 = $result_values->panduan_22;
	   $panduan_23 = $result_values->panduan_23;
	   $panduan_24 = $result_values->panduan_24;
	   $panduan_25 = $result_values->panduan_25;
	   $panduan_26 = $result_values->panduan_26;
	   $panduan_27 = $result_values->panduan_27;
	   $panduan_28 = $result_values->panduan_28;
	   $panduan_fuhexing2 = $result_values->panduan_fuhexing2;
	   $panduan_final = $result_values->panduan_final;
	   $shenheren = $result_values->shenheren ;
	   $shenheshijian = $result_values->shenheshijian;
	}
	$form['tips'] = array(
	  '#prefix' =>'<div id="tips">',
	  '#markup' => t('<span class="form-required">*</span> 号为必填项。'),
	  '#suffix' =>'</div>',
	 );
	 $form["perid"] = array(
		"#type" => "hidden",
		"#value" => $xiangmu_id, 
	);
	 $form["fuhe_panduanid"] = array(
		"#type" => "hidden",
		"#value" => $fuhe_panduanid, 
	);
	 $form['jieduan'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<table border=\"1\" width=\"500px\"><tr><center><th colspan=2>考察项目</th></center></tr><tr><th colspan=2>一、项目阶段判断</th></tr><tr><th>本项目所属阶段</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $jieduan,
	   );
	 $form['bili_jieduan1'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>要求投资青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_jieduan1,
	   );
	 $form['bili_jieduan2'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>已投资非青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_jieduan2,
	   );
	 $form['bili_jieduan3'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资非青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_jieduan3,
	   );
	   $form['panduan_jieduan'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_jieduan,
	 );	  
	 
	 $form['bili_diyu1'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>二、投资地域判断</th></tr><tr><th>投资青岛比例要求</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_diyu1,
	   );
	   $form['bili_diyu2'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>已冲抵比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_diyu2,
	   );
	    $form['bili_diyu3'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本基金已累计投资外地项目比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_diyu3,
	   );
	    $form['bili_diyu4'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>投资青岛比例要求</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_diyu4,
	   );
	    $form['bili_diyu5'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资外地项目比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_diyu5,
	   );
	  $form['panduan_diyu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_diyu,
	 );	  
	 
	 $form['lingyu'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>三、投资领域判断</th></tr><tr><th>本项目属于领域</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $lingyu,
	   );
	   $form['bili_lingyu1'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本基金要求投资领域及比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_lingyu1,
	   );
	    $form['bili_lingyu2'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>累计投资于该基金主投领域比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_lingyu2,
	   );
	    $form['bili_lingyu3'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>累计投资于该基金主投领域之外比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_lingyu3,
	   );
	    $form['bili_lingyu4'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资于该基金主投领域之外比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_lingyu4,
	   );
	  $form['panduan_lingyu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_lingyu,
	 );	  
	 
	 $form['bili_danxiangmu1'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>四、单个项目投资比例</th></tr><tr><th>本项目属于领域</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_danxiangmu1,
	   );
	   $form['bili_danxiangmu2'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本项目累计比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $bili_danxiangmu2,
	   );
	   $form['panduan_danxiangmu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_danxiangmu,
	 );	  
	 $form['panduan_danxiangmu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_danxiangmu,
	 );	
	  $form['panduan_fuhexing1'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>合规性审查结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_fuhexing1,
	 );	
	 
	 $form['panduan_11'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>五、五个基本方面</th></tr><tr><th>1、项目不涉及从事与创业投资无关的业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_11,
	 );	
	  $form['panduan_12'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>2、项目不违背国家产业政策及青岛城市功能定位(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_12,
	 );	
	  $form['panduan_13'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>3、项目不违背有关法律法规要求(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_13,
	 );	  
	  $form['panduan_14'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>4、项目不违背基金有关文件约定(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_14,
	 );	
	 $form['panduan_15'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>5、投资决策委员会及其成员不存在故意的不当行为或重大过失等(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_15,
	 );	
	   
	   $form['panduan_21'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>六、禁止事项</th></tr><tr><th> 1、不得对已上市企业进行股权投资，但是所投资的未上市企业上后，其所持股权的未转让部分及其配售部分不在此限(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_21,
	 );	
	  $form['panduan_22'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th> 2、不得投资于合伙或有限合伙企业及其他承担无限责任的任何企业(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_22,
	 );	
	  $form['panduan_23'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得投资于其他创业投资企业(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_23,
	 );	  
	  $form['panduan_24'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得吸收或变相吸收存款、贷款、拆借(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_24,
	 );	
	 $form['panduan_25'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事期货及金融衍生品交易业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_25,
	 );
	 $form['panduan_26'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事抵押或其他担保业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_26,
	 );	  
	  $form['panduan_27'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得进行赞助和捐赠(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_27,
	 );	
	 $form['panduan_28'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事期货及金融衍生品交易业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_28,
	 );	
	   	
	 $form['panduan_fuhexing2'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>合规性审查结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_fuhexing2,
	 );	
	 $form['panduan_final'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>最终结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_final,
	 );	
	  
	  $form['shenheren'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>审核人</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $shenheren,
	   );
	  $form['shenheshijian'] = array(
	  '#type' => 'textfield',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>审核时间</th><td>",
	  "#suffix" => "</td></tr></table>",
	  "#default_value" => $shenheshijian,
	   );
	   
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('确认'),
	  );
	  return $form;
}

function xiangmu_fuhe_panduan_form_submit($form, &$form_state)
{
	$values = $form_state["values"];
	 $query = "SELECT fund_id FROM " .
           "{xiangmu_info} where id = ?";
	 $queryResult = db_query($query, array($values['perid']));
	 $fund_id = 0;
	 foreach ($queryResult as $result_values)
	 {
		$fund_id = $result_values->fund_id;
	 }
	if($values["fuhe_panduanid"]>0){
		db_update('xiangmu_fuhe_panduan')
	  		->fields(array(
	   			 'jieduan' =>  $values['jieduan'],
	   			 'bili_jieduan1' => $values['bili_jieduan1'],
	   			 'bili_jieduan2' => $values['bili_jieduan2'],
	   			 'bili_jieduan3' =>  $values['bili_jieduan3'],
	   			 'panduan_jieduan' => $values['panduan_jieduan'],
	   			 'bili_diyu1' => $values['bili_diyu1'],
	   			 'bili_diyu2' =>  $values['bili_diyu2'],
	   			 'bili_diyu3' =>  $values['bili_diyu3'],
	   			 'bili_diyu4' => $values['bili_diyu4'],
	   			 'bili_diyu5' => $values['bili_diyu5'],
	   			 'panduan_diyu' =>  $values['panduan_diyu'],
	   			 'lingyu' => $values['lingyu'],
	   			 'bili_lingyu1' => $values['bili_lingyu1'],
	   			 'bili_lingyu2' =>  $values['bili_lingyu2'],	
	   			 'bili_lingyu3' =>  $values['bili_lingyu3'],
	   			 'bili_lingyu4' => $values['bili_lingyu4'],
	   			 'panduan_lingyu' => $values['panduan_lingyu'],
	   			 'bili_danxiangmu1' =>  $values['bili_danxiangmu1'], 
	   			 'bili_danxiangmu2' => $values['bili_danxiangmu2'],
	   			 'panduan_danxiangmu' => $values['panduan_danxiangmu'],
	   			 'panduan_fuhexing1' =>  $values['panduan_fuhexing1'],
	   			 'panduan_11' =>  $values['panduan_11'],
	   			 'panduan_12' => $values['panduan_12'],
	   			 'panduan_13' => $values['panduan_13'],
	   			 'panduan_14' => $values['panduan_14'],
	   			 'panduan_15' => $values['panduan_15'],
	   			 'panduan_21' => $values['panduan_21'],
	   			 'panduan_22' =>  $values['panduan_22'],  			 
				 'panduan_23' =>  $values['panduan_23'],
	   			 'panduan_24' => $values['panduan_24'],
	   			 'panduan_25' => $values['panduan_25'],
	   			 'panduan_26' => $values['panduan_26'],
	   			 'panduan_27' => $values['panduan_27'],
	   			 'panduan_28' => $values['panduan_28'],
	   			 'panduan_22' =>  $values['panduan_22'],
	   			 'panduan_fuhexing2' => $values['panduan_fuhexing2'],
	   			 'panduan_final' => $values['panduan_final'],
	   			 'shenheren' => $values['shenheren'],
	   			 'shenheshijian' =>  $values['shenheshijian'],	
	  			))
	  			->condition('id', $values["fuhe_panduanid"])
	  			->execute();
	   $form_state['redirect'] = 'toujuehui_xiangmu/list';
	}		
	else{
		$lastid = db_insert('xiangmu_fuhe_panduan')
	  		->fields(array(
	  		     'xiangmu_id' =>$values['perid'],
	   			  'jieduan' =>  $values['jieduan'],
	   			 'bili_jieduan1' => $values['bili_jieduan1'],
	   			 'bili_jieduan2' => $values['bili_jieduan2'],
	   			 'bili_jieduan3' =>  $values['bili_jieduan3'],
	   			 'panduan_jieduan' => $values['panduan_jieduan'],
	   			 'bili_diyu1' => $values['bili_diyu1'],
	   			 'bili_diyu2' =>  $values['bili_diyu2'],
	   			 'bili_diyu3' =>  $values['bili_diyu3'],
	   			 'bili_diyu4' => $values['bili_diyu4'],
	   			 'bili_diyu5' => $values['bili_diyu5'],
	   			 'panduan_diyu' =>  $values['panduan_diyu'],
	   			 'lingyu' => $values['lingyu'],
	   			 'bili_lingyu1' => $values['bili_lingyu1'],
	   			 'bili_lingyu2' =>  $values['bili_lingyu2'],	
	   			 'bili_lingyu3' =>  $values['bili_lingyu3'],
	   			 'bili_lingyu4' => $values['bili_lingyu4'],
	   			 'panduan_lingyu' => $values['panduan_lingyu'],
	   			 'bili_danxiangmu1' =>  $values['bili_danxiangmu1'], 
	   			 'bili_danxiangmu2' => $values['bili_danxiangmu2'],
	   			 'panduan_danxiangmu' => $values['panduan_danxiangmu'],
	   			 'panduan_fuhexing1' =>  $values['panduan_fuhexing1'],
	   			 'panduan_11' =>  $values['panduan_11'],
	   			 'panduan_12' => $values['panduan_12'],
	   			 'panduan_13' => $values['panduan_13'],
	   			 'panduan_14' => $values['panduan_14'],
	   			 'panduan_15' => $values['panduan_15'],
	   			 'panduan_21' => $values['panduan_21'],
	   			 'panduan_22' =>  $values['panduan_22'],  			 
				 'panduan_23' =>  $values['panduan_23'],
	   			 'panduan_24' => $values['panduan_24'],
	   			 'panduan_25' => $values['panduan_25'],
	   			 'panduan_26' => $values['panduan_26'],
	   			 'panduan_27' => $values['panduan_27'],
	   			 'panduan_28' => $values['panduan_28'],
	   			 'panduan_22' =>  $values['panduan_22'],
	   			 'panduan_fuhexing2' => $values['panduan_fuhexing2'],
	   			 'panduan_final' => $values['panduan_final'],
	   			 'shenheren' => $values['shenheren'],
	   			 'shenheshijian' =>  $values['shenheshijian'],				 
	  			))->execute();
		  if ($lastid!=NULL) {
				 $form_state['redirect'] = 'toujuehui_xiangmu/list';
			  } else {
			    drupal_set_message('抱歉，遇到问题，提交失败了', 'error');    
			  }	
		
	}  
			
}

function xiangmu_fuhe_panduan_view_page($perid)
{
	$html = array("#markup" => "");
	$html["#markup"] .= l("返回列表","toujuehui_manage/list").'<br><br>';
	$query = "SELECT * FROM " .
           "{xiangmu_fuhe_panduan} where id = ?";
   $queryResult = db_query($query, array($perid));
   $ifempty =TRUE;
   foreach ($queryResult as $links ) {
	  if($links->id>0)
		  $ifempty = FALSE;
   }
   if($ifempty)
	 {
	 	 $html["#markup"] .= "尚未填写该项目的符合性审查表信息！";
	 }
   else{
   		$view_form = drupal_get_form("xiangmu_fuhe_panduan_view_form",$perid);
		$html["#markup"] .= drupal_render($view_form);
   }
	return $html;
}

function xiangmu_fuhe_panduan_view_form($form, &$form_state,$perid){
   $query = "SELECT * FROM " .
           "{xiangmu_fuhe_panduan} where id = ?";
   $queryResult = db_query($query, array($perid));
   $fuhe_panduanid = 0;
   $jieduan = "";
   $bili_jieduan1 = "";
   $bili_jieduan2 = "";
   $bili_jieduan3 = "";
   $panduan_jieduan = 0;
   $bili_diyu1 = "";
   $bili_diyu2 = "";
   $bili_diyu3 = "";
   $bili_diyu4 = "";
   $bili_diyu5 = "";
   $panduan_diyu = 0;
   $lingyu = "";
   $bili_lingyu1 = "";
   $bili_lingyu2 = "";
   $bili_lingyu3 = "";
   $bili_lingyu4 = "";
   $panduan_lingyu = 0;
   $bili_danxiangmu1 = "";
   $bili_danxiangmu2 = "";
   $panduan_danxiangmu = 0;
   $panduan_fuhexing1 = 0;
   $panduan_11 = 0;
   $panduan_12 = 0;
   $panduan_13 = 0;
   $panduan_14 = 0;
   $panduan_15 = 0;
   $panduan_21 = 0;
   $panduan_22 = 0;
   $panduan_23 = 0;
   $panduan_24 = 0;
   $panduan_25 = 0;
   $panduan_26 = 0;
   $panduan_27 = 0;
   $panduan_28 = 0;
   $panduan_fuhexing2 = 0;
   $panduan_final = 0;
   $shenheren = "";
   $shenheshijian = "";
   
	foreach ($queryResult as $result_values)
	{
	    $fuhe_panduanid = $result_values->id;
	   $jieduan = $result_values->jieduan;
	   $bili_jieduan1 = $result_values->bili_jieduan1;
	   $bili_jieduan2 = $result_values->bili_jieduan2;
	   $bili_jieduan3 = $result_values->bili_jieduan3;
	   $panduan_jieduan = $result_values->panduan_jieduan;
	   $bili_diyu1 = $result_values->bili_diyu1;
	   $bili_diyu2 = $result_values->bili_diyu2;
	   $bili_diyu3 = $result_values->bili_diyu3;
	   $bili_diyu4 = $result_values->bili_diyu4;
	   $bili_diyu5 = $result_values->bili_diyu5;
	   $panduan_diyu = $result_values->panduan_diyu;
	   $lingyu = $result_values->lingyu;
	   $bili_lingyu1 = $result_values->bili_lingyu1;
	   $bili_lingyu2 = $result_values->bili_lingyu2;
	   $bili_lingyu3 = $result_values->bili_lingyu3;
	   $bili_lingyu4 = $result_values->bili_lingyu4;
	   $panduan_lingyu = $result_values->panduan_lingyu;
	   $bili_danxiangmu1 = $result_values->bili_danxiangmu1;
	   $bili_danxiangmu2 = $result_values->bili_danxiangmu2;
	   $panduan_danxiangmu = $result_values->panduan_danxiangmu;
	   $panduan_fuhexing1 = $result_values->panduan_fuhexing1;
	   $panduan_11 = $result_values->panduan_11;
	   $panduan_12 = $result_values->panduan_12;
	   $panduan_13 = $result_values->panduan_13;
	   $panduan_14 = $result_values->panduan_14;
	   $panduan_15 = $result_values->panduan_15;
	   $panduan_21 = $result_values->panduan_21;
	   $panduan_22 = $result_values->panduan_22;
	   $panduan_23 = $result_values->panduan_23;
	   $panduan_24 = $result_values->panduan_24;
	   $panduan_25 = $result_values->panduan_25;
	   $panduan_26 = $result_values->panduan_26;
	   $panduan_27 = $result_values->panduan_27;
	   $panduan_28 = $result_values->panduan_28;
	   $panduan_fuhexing2 = $result_values->panduan_fuhexing2;
	   $panduan_final = $result_values->panduan_final;
	   $shenheren = $result_values->shenheren ;
	   $shenheshijian = $result_values->shenheshijian;
	}
	  $form['jieduan'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<table border=\"1\" width=\"500px\"><tr><th colspan=2>考察项目</th></tr><tr><th colspan=2>一、项目阶段判断：</th></tr><tr><th>本项目所属阶段</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $jieduan,
	   );
	 $form['bili_jieduan1'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>要求投资青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_jieduan1,
	   );
	 $form['bili_jieduan2'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>已投资非青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_jieduan2,
	   );
	 $form['bili_jieduan3'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资非青岛初创期早中期比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_jieduan3,
	   );
	   $form['panduan_jieduan'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_jieduan,
	 );	  
	 
	 $form['bili_diyu1'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>二、投资地域判断：</th></tr><tr><th>投资青岛比例要求</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_diyu1,
	   );
	   $form['bili_diyu2'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>已冲抵比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_diyu2,
	   );
	    $form['bili_diyu3'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本基金已累计投资外地项目比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_diyu3,
	   );
	    $form['bili_diyu4'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>投资青岛比例要求</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_diyu4,
	   );
	    $form['bili_diyu5'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资外地项目比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_diyu5,
	   );
	  $form['panduan_diyu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_diyu,
	 );	  
	 
	 $form['lingyu'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>三、投资领域判断</th></tr><tr><th>本项目属于领域</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $lingyu,
	   );
	   $form['bili_lingyu1'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本基金要求投资领域及比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_lingyu1,
	   );
	    $form['bili_lingyu2'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>累计投资于该基金主投领域比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_lingyu2,
	   );
	    $form['bili_lingyu3'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>累计投资于该基金主投领域之外比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_lingyu3,
	   );
	    $form['bili_lingyu4'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>尚可投资于该基金主投领域之外比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_lingyu4,
	   );
	  $form['panduan_lingyu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_lingyu,
	 );	  
	 
	 $form['bili_danxiangmu1'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>四、单个项目投资比例</th></tr><tr><th>本项目属于领域</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_danxiangmu1,
	   );
	   $form['bili_danxiangmu2'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>本项目累计比例</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $bili_danxiangmu2,
	   );
	   $form['panduan_danxiangmu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_danxiangmu,
	 );	  
	 $form['panduan_danxiangmu'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>判断结果(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_danxiangmu,
	 );	
	  $form['panduan_fuhexing1'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>合规性审查结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_fuhexing1,
	 );	
	 
	 $form['panduan_11'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>五、五个基本方面</th></tr><tr><th>1、项目不涉及从事与创业投资无关的业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_11,
	 );	
	  $form['panduan_12'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>2、项目不违背国家产业政策及青岛城市功能定位(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_12,
	 );	
	  $form['panduan_13'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>3、项目不违背有关法律法规要求(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_13,
	 );	  
	  $form['panduan_14'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>4、项目不违背基金有关文件约定(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_14,
	 );	
	 $form['panduan_15'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>5、投资决策委员会及其成员不存在故意的不当行为或重大过失等(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_15,
	 );	
	   
	   $form['panduan_21'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th colspan=2>六、禁止事项</th></tr><tr><th> 1、不得对已上市企业进行股权投资，但是所投资的未上市企业上后，其所持股权的未转让部分及其配售部分不在此限(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_21,
	 );	
	  $form['panduan_22'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th> 2、不得投资于合伙或有限合伙企业及其他承担无限责任的任何企业(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_22,
	 );	
	  $form['panduan_23'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得投资于其他创业投资企业(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_23,
	 );	  
	  $form['panduan_24'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得吸收或变相吸收存款、贷款、拆借(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_24,
	 );	
	 $form['panduan_25'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事期货及金融衍生品交易业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_25,
	 );
	 $form['panduan_26'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事抵押或其他担保业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_26,
	 );	  
	  $form['panduan_27'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得进行赞助和捐赠(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_27,
	 );	
	 $form['panduan_28'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>不得从事期货及金融衍生品交易业务(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_28,
	 );	
	   	
	 $form['panduan_fuhexing2'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>合规性审查结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_fuhexing2,
	 );	
	 $form['panduan_final'] = array(
	  "#type" => "checkbox",
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>最终结论(符合打勾)</th><td>",
	  "#suffix" => "</td></tr>",
	  "#default_value" => $panduan_final,
	 );	
	  
	  $form['shenheren'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>审核人</th><td>",
	  "#suffix" => "</td></tr>",
	  "#markup" => $shenheren,
	   );
	  $form['shenheshijian'] = array(
	  '#type' => 'item',
	  '#required' => FALSE,
	  "#prefix" => "<tr><th>审核时间</th><td>",
	  "#suffix" => "</td></tr></table>",
	  "#markup" => $shenheshijian,
	   );
	  return $form;
}

//////////
//被投企业项目退出
//////////
function xiangmu_exit_create($qiye_id){
	  //我们为这个页面设置标题
	 drupal_set_title('新增项目退出信息');
	 $page_content = '';
	 $query = "SELECT fund_id, user_id FROM " .
           "{xiangmu_info} where id = ?";
    $queryResult = db_query($query, array($qiye_id));
	$ifempty = TRUE;
	global $user;
    foreach ($queryResult as $result) {
    	if($user->uid != $result->user_id){
    		drupal_goto('qiye_tcbg_file/list');		
    	}
		$ifempty = FALSE;
        $page_content .= l('返回列表','qiye_tcbg_file/list') . '<br />'. '<br />';    
    }
	if($ifempty)
		drupal_goto('qiye_tcbg_file/list');

	 $render_array = array(
	   '#markup' => $page_content, 
	 );
	 
	 $form = drupal_get_form('xiangmu_exit_form',$qiye_id);
	 $render_array['#markup'] .= drupal_render($form);
	 
	 return $render_array;
}

function xiangmu_exit_form($form, &$form_state, $qiye_id){
	 $form['bid'] = array('#type' => 'hidden', '#value' => $qiye_id);
	 
	 $form['tips'] = array(
	  '#prefix' =>'<div id="tips">',
	  '#markup' => t('<span class="form-required">*</span> 号为必填项。'),
	  '#suffix' =>'</div>',
	 );
	 
	 $form['exit_money'] = array(
	  '#title' => t('项目退出金额（万元）'),
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['exit_money'])?$_SESSION['xiangmu_exit_form']['exit_money']:"",
	  //'#description' => t('例如：250.55'),
	 );
	 $today = getdate();
     $form['exit_timestamp'] = array(
	     '#type' => 'date', // types 'date_popup', 'date_text' and 'date_timezone' are also supported. See .inc file.
	     '#title' => t('退出时间'),
	     '#default_value' => array('year' =>  $today['year'], 'month' =>  $today['mon'], 'day' => $today['mday']), 
	 );
	 $form['exit_type'] = array(
	  '#title' => t('退出方式'),
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['exit_type'])?$_SESSION['xiangmu_exit_form']['exit_type']:"",
	 ); 
	 $form['remark'] = array(
	  '#title' => t('备注'),
	  '#type' => 'textarea',
	  '#required' => FALSE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['remark'])?$_SESSION['xiangmu_exit_form']['remark']:"",
	 );
	
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('确认退出'),
	  );
	  return $form;
}

function xiangmu_exit_form_validate($form, &$form_state){
	  if (drupal_strlen($form_state['values']['exit_money']) > 15) {
	    form_set_error('exit_money', '要求精度小于15 个字符');
	  } 
	  if (!($form_state['values']['exit_money']>=0)) {
	    form_set_error('exit_money', '请输入正数');
	  }  
}

function xiangmu_exit_form_submit($form, &$form_state){
	  //把表单的值存放在会话中去，由于这里涉及到了两个不同的表单之间传值。
	 $_SESSION['xiangmu_exit_form'] = $form_state['values'];
	 //表单重定向到确认页面
	 $form_state['redirect'] = 'xiangmu_exit/confirm';
}
 
function xiangmu_exit_confirm_page(){
  //我们为这个页面设置标题
	 drupal_set_title('新增项目退出信息');
	 
	 //这里首先作了判断，如果会话中没有设置contactus_form，返回contactus
	 if(empty($_SESSION['xiangmu_exit_form'])){
	  drupal_goto('qiye_tcbg_file/fundlist');
	 }	
	 $render_array = array(
	   '#markup' => '', 
	 );
	 //该页面的正文为一个表单，注意对于表单，这里需要使用drupal_render呈现一下。
	 $form = drupal_get_form('xiangmu_exit_confirm_form');
	 $render_array['#markup'] .= drupal_render($form);
	 //Drupal7的页面回调，返回的应该是一个数组
	 return $render_array;
}

function xiangmu_exit_confirm_form(){
     
     $form['exit_money'] = array(
	  '#title' => t('项目退出金额（万元）'),
	  '#type' => 'item',
	  '#markup' =>isset($_SESSION['xiangmu_exit_form']['exit_money'])?$_SESSION['xiangmu_exit_form']['exit_money']:"",
	 );
	 $exit_timestamp = $_SESSION['xiangmu_exit_form']['exit_timestamp'];
     $form['exit_timestamp'] = array(
	     '#type' => 'date', // types 'date_popup', 'date_text' and 'date_timezone' are also supported. See .inc file.
	     '#title' => t('退出时间'),
	     '#markup' => isset($_SESSION['xiangmu_exit_form']['exit_timestamp'])?$exit_timestamp['year'].'年'.$exit_timestamp['month'].'月'.$exit_timestamp['day'].'日':"", 
	 );
	 $form['exit_type'] = array(
	  '#title' => t('退出方式'),
	  '#type' => 'item',
	  '#markup' =>isset($_SESSION['xiangmu_exit_form']['exit_type'])?$_SESSION['xiangmu_exit_form']['exit_type']:"",
	 ); 
	 
	 $form['remark'] = array(
	  '#title' => t('备注'),
	  '#type' => 'item',
	  '#markup' =>isset($_SESSION['xiangmu_exit_form']['remark'])?$_SESSION['xiangmu_exit_form']['remark']:"",
	 );

	  $form['back'] = array(
	    '#type' => 'submit',
	    '#value' => t('返回'),
	    '#submit' => array('xiangmu_exit_confirm_form_back'),
	  );
	
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('提交'),
	  );
	  
	  return $form;
}

function xiangmu_exit_confirm_form_back($form, &$form_state){
 $form_state['redirect'] = 'xiangmu_exit/create/'.$_SESSION['xiangmu_exit_form']['bid'];
}

function xiangmu_exit_confirm_form_submit($form, &$form_state){
		/**
	   * 写入数据库
	   */
	  $values = NULL;
	  global  $user;
	  if(empty($_SESSION['xiangmu_exit_form'])){
		  drupal_goto('xiangmu_exit/create/'.$values['bid']);
	  }else{
		  $values = $_SESSION['xiangmu_exit_form'];
		  unset($_SESSION['xiangmu_exit_form']);
	  }
      $exit_timestamp = mktime(0, 0, 0,$values['exit_timestamp']['month'], $values['exit_timestamp']['day'], $values['exit_timestamp']['year']);
	  $query = "SELECT fund_id FROM " .
           "{xiangmu_info} where id = ?";
	  $queryResult = db_query($query, array($values['bid']));
	  $fund_id = '';
	  foreach ($queryResult as $result) {
	  	$fund_id = $result->fund_id;
	  }
	  global $user;
	  $last_id = db_insert('xiangmu_exit_info')
  		->fields(array(
  		     'fund_id' => $fund_id,
  		     'user_id' => $user->uid,
  		     'xiangmu_id' => $values['bid'],
   			 'exit_timestamp' => $exit_timestamp,  			 
   			 'exit_type' => $values['exit_type'],
   			 'exit_money' => $values['exit_money'],
   			 'remark' => $values['remark'],
  			))->execute();
	  if ($last_id!=NULL) {
	  	  db_update('xiangmu_info')
		 	->fields(array(
		   		'state' =>  3,
		   		))
			->condition('id', $values['bid'])
		  	->execute();	
		 $form_state['redirect'] = 'qiye_tcbg_file/list';
	  } else {
	    
	    // 数据写入失败了
	    drupal_set_message('抱歉，遇到问题，提交失败了', 'error');
	    
	  }	
}

//传人基金id
function xiangmu_exit_list_page() {
  $html = '';	
  $html .= '<br><h3>未退出项目列表</h3><br>';
  $header = array(
      array('data' => '序号'),
      array('data' => '项目', 'field' => 'company_name'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '退出时间', 'field' => 'exit_timestamp'),
      array('data' => '退出金额（万元）', 'field' => 'exit_money'),
      array('data' => '退出方式', 'field' => 'exit_type'),
      array('data' => '详情'),
      );
  global $user;
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(20)//20 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      ))
	  ->condition('user_id',$user->uid,'=')
	  ->condition('state',1,'=');
  $results = $query
      ->execute();

  $rows = array();
  $_serial_num = 1;
  foreach ($results as $node) {
  	 $query = "SELECT fund_id,exit_timestamp,exit_type,exit_money FROM " .
           "{xiangmu_exit_info} where xiangmu_id = ?";
	  $queryResult = db_query($query, array($node->id));
	  $fund_id = '';
	  $exit_timestamp = '';
	  $exit_type = '';
	  $exit_money = '';
	  foreach ($queryResult as $result) {
	  	$fund_id = $result->fund_id;
		$exit_timestamp = str_replace(array(',',",",'，',"，") , " ", format_date($result->exit_timestamp, 'custom', 'Y-m-d'));
		$exit_type = $result->exit_type;
		$exit_money = $result->exit_money;
	  }
      $rows[] = array(
      'data' => array(
        $_serial_num,
        l($node->company_name, 'xiangmu/view/'. $node->id),
        $node->locality,
        $exit_timestamp,
        $exit_money,
        $exit_type,
         l('设置', 'xiangmu_exit/create/'. $node->id),
      )
      );
	  $_serial_num++;
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目退出信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= '</div>';
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  
   $html .= '<br><h3>已退出项目列表</h3><br>';
  $header = array(
      array('data' => '序号'),
      array('data' => '项目', 'field' => 'company_name'),
      array('data' => '所属地区', 'field' => 'locality'),
      array('data' => '退出时间', 'field' => 'exit_timestamp'),
      array('data' => '退出金额（万元）', 'field' => 'exit_money'),
      array('data' => '退出方式', 'field' => 'exit_type'),
      array('data' => '详情'),
      );
  global $user;
  $query = db_select('xiangmu_info', 'n')
      ->extend('PagerDefault') //Pager Extender
      ->limit(20)//20 results per page
      ->extend('TableSort')//Sorting Extender
      ->orderByHeader($header)//Field to sort on is picked from $header
      ->fields ('n', array (
      'id',
      'company_name',
      'locality',
      ))
	  ->condition('user_id',$user->uid,'=')
	  ->condition('state',3,'=');
  $results = $query
      ->execute();

  $rows = array();
  $_serial_num = 1;
  foreach ($results as $node) {
  	 $query = "SELECT fund_id,exit_timestamp,exit_type,exit_money FROM " .
           "{xiangmu_exit_info} where xiangmu_id = ?";
	  $queryResult = db_query($query, array($node->id));
	  $fund_id = '';
	  $exit_timestamp = '';
	  $exit_type = '';
	  $exit_money = '';
	  foreach ($queryResult as $result) {
	  	$fund_id = $result->fund_id;
		$exit_timestamp = str_replace(array(',',",",'，',"，") , " ", format_date($result->exit_timestamp, 'custom', 'Y-m-d'));
		$exit_type = $result->exit_type;
		$exit_money = $result->exit_money;
	  }
      $rows[] = array(
      'data' => array(
        $_serial_num,
        l($node->company_name, 'xiangmu/view/'. $node->id),
        $node->locality,
        $exit_timestamp,
        $exit_money,
        $exit_type,
         l('查看', 'xiangmu_exit/list/'. $node->id),
      )
      );
	  $_serial_num++;
  }
  $html .= theme('table', 
      array(
            'header' => $header,
            'rows'=>$rows,
            //'caption' => '反馈意见列表',//Optional Caption for the table
            'sticky' => TRUE,//Optional to indicate whether the table headers should be sticky
            'empty' => '没有项目退出信息',//Optional empty text for the table if resultset is empty
      )
      );
  $html .= '</div>';
  $html .= theme('pager',
      array(
            'tags' => array()
      )
      );
  
  return ($html); 
}
//传人项目退出id
function xiangmu_exit_per_page($perid) {
 
  // content variable that will be returned for display
  $page_content = '';
  $query = "SELECT fund_id FROM " .
           "{xiangmu_exit_info} where id = ?";
  $queryResult = db_query($query, array($perid));
  foreach ($queryResult as $result) {
     $page_content .= l('返回列表','qiye_tcbg_file/list') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';     
  }
 	 
  $render_array = array(
	   '#markup' => $page_content,
	 );
	 
	 //该页面的正文为一个表单，注意对于表单，这里需要使用drupal_render呈现一下。
  if(user_access('xiangmu manage')){
  	$form = drupal_get_form('xiangmu_exit_edit_form',$perid);
  	$render_array['#markup'] .= drupal_render($form);
  }
  else{
  	$form = drupal_get_form('xiangmu_exit_view_form',$perid);
  	$render_array['#markup'] .= drupal_render($form);
  }
  
  $render_array['#markup'] .= '</div>';
	 //Drupal7的页面回调，返回的应该是一个数组
  return $render_array;
}

function xiangmu_exit_view_form($form, &$form_state, $perid){
  $query = "SELECT * FROM " .
           "{xiangmu_exit_info} where id = ?";
  $queryResult = db_query($query, array($perid));
  $exit_timestamp = '';   
  $exit_type = '';
  $exit_money = '';
  $remark = '';

  foreach ($queryResult as $links ) {
	  $exit_timestamp =  format_date($links->exit_timestamp, 'custom', 'Y-m-d');
	  $exit_type = $links->exit_type;
	  $exit_money = $links->exit_money;
	  $remark = $links->remark;
  }
  // More coming....
  if ($queryResult == '') {
    $form = NULL;
  }
  else{
   $form['bid'] = array('#type' => 'hidden', '#value' => $perid);

     $form['exit_timestamp'] = array(
	     '#type' => 'item',
	  	 "#markup" => $exit_timestamp ,
	     '#title' => t('退出时间'),
	 );
	 $form['exit_money'] = array(
	  '#title' => t('退出金额（万元）'),
	  '#type' => 'item',
	  "#markup" => $exit_money,
	  
	 ); 
	 $form['exit_type'] = array(
	  '#title' => t('退出方式'),
	  '#type' => 'item',
	  "#markup" => $exit_type,

	 ); 
	 $form['remark'] = array(
	  '#title' => t('备注'),
	  '#type' => 'item',
	  "#markup" => $remark,

	 );	
  }
  
  return $form;
}


function xiangmu_exit_edit_form($form, &$form_state, $perid){
  $query = "SELECT * FROM " .
           "{xiangmu_exit_info} where id = ?";
  $queryResult = db_query($query, array($perid));
  $exit_timestamp = '';   
  $exit_type = '';
  $exit_money = '';
  $remark = '';
  $if_empty = TRUE;
  foreach ($queryResult as $links ) {
  	$if_empty  = FALSE;
	  $exit_timestamp =  getdate($links->exit_timestamp);
	  $exit_type = $links->exit_type;
	  $exit_money = $links->exit_money;
	  $remark = $links->remark;
  }
  // More coming....
  if ($if_empty) {
    drupal_goto('qiye_tcbg_file/list');
  }
  else{
   $form['bid'] = array('#type' => 'hidden', '#value' => $perid);

     $form['exit_timestamp'] = array(
	     '#type' => 'date', // types 'date_popup', 'date_text' and 'date_timezone' are also supported. See .inc file.
	     '#title' => t('退出时间'),
	     '#default_value' => array('year' =>  $exit_timestamp['year'], 'month' =>  $exit_timestamp['mon'], 'day' => $exit_timestamp['mday']), 
	 );
	 $form['exit_money'] = array(
	  '#title' => t('退出金额（万元）'),
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['exit_money'])?$_SESSION['xiangmu_exit_form']['exit_money']:$exit_money,
	  '#description' => t('例如：250.55'),
	 ); 
	 $form['exit_type'] = array(
	  '#title' => t('退出方式'),
	  '#type' => 'textfield',
	  '#required' => TRUE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['exit_type'])?$_SESSION['xiangmu_exit_form']['exit_type']:$exit_type,
	 ); 
	 $form['remark'] = array(
	  '#title' => t('备注'),
	  '#type' => 'textarea',
	  '#required' => FALSE,
	  '#default_value' =>isset($_SESSION['xiangmu_exit_form']['remark'])?$_SESSION['xiangmu_exit_form']['remark']:$remark,
	 );
	  $form['submit'] = array(
	    '#type' => 'submit',
	    '#value' => t('提交修改'),
	  );
	  
	 //表单元素“提交”按钮
	  $form['deleate'] = array(
	    '#type' => 'submit',
	    '#value' => t('删除该企业信息'),
	    '#submit' => array('xiangmu_exit_edit_form_deleate'),
	  );
  	
  }
  
  return $form;
}

function xiangmu_exit_edit_form_submit($form, &$form_state){
	  $values = NULL;
	  $values = $form_state['values'];
      $exit_timestamp = mktime(0, 0, 0,$values['exit_timestamp']['month'], $values['exit_timestamp']['day'], $values['exit_timestamp']['year']);
	   db_update('xiangmu_exit_info')
  		->fields(array(
             'exit_timestamp' => $exit_timestamp,
   			 'exit_money' => $values['exit_money'],
   			 'exit_type' => $values['exit_type'],
   			 'remark' => $values['remark'],
  			))
  		->condition('id', $values['bid'])
  		->execute();
	 $form_state['redirect'] = 'qiye_tcbg_file/list';
}

function xiangmu_exit_edit_form_deleate($form, &$form_state){
	 $values = NULL;
	 $_SESSION['xiangmu_exit_edit_form'] = $form_state['values'];
	 $values = $_SESSION['xiangmu_exit_edit_form'] ;
	 //表单重定向到确认页面
	 $form_state['redirect'] = 'xiangmu_exit/deleate/'.$values['bid'];
}

function xiangmu_exit_deleate_page($perid) {
  // content variable that will be returned for display
  $page_content = '删除后该项目退出信息将不可恢复！';
  
  drupal_set_title('删除该项目退出信息');
	 
	 $render_array = array(
	   '#markup' => $page_content,
	 );
	 
	 //该页面的正文为一个表单，注意对于表单，这里需要使用drupal_render呈现一下。
	 $form = drupal_get_form('xiangmu_exit_deleate_form');
	 $render_array['#markup'] .= drupal_render($form);
	 
	 //Drupal7的页面回调，返回的应该是一个数组
  return $render_array;

}

function xiangmu_exit_deleate_form($form, &$form_state){
 //表单元素“返回”按钮
  $form['back'] = array(
    '#type' => 'submit',
    '#value' => t('取消'),
    '#submit' => array('xiangmu_exit_deleate_form_back'),
  );
 //表单元素“提交”按钮
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('删除'),
  );
  
  return $form;
}

function xiangmu_exit_deleate_form_back($form, &$form_state){
	if(empty($_SESSION['xiangmu_exit_edit_form'])){
		  //drupal_goto('contact');
		  $form_state['redirect'] = 'qiye_tcbg_file/list';
	  }else{
		  $values = $_SESSION['xiangmu_exit_edit_form'];
		  unset($_SESSION['xiangmu_exit_edit_form']);
		  $form_state['redirect'] = 'xiangmu_exit/list/'.$values['bid'];
	  }
}

function xiangmu_exit_deleate_form_submit($form, &$form_state){
  //简单的重定向到contactus页面
 if(empty($_SESSION['xiangmu_exit_edit_form'])){
		  //drupal_goto('contact');
		  $form_state['redirect'] = 'qiye_tcbg_file/fundlist/';
	  }else{
		  $values = $_SESSION['xiangmu_exit_edit_form'];
		  unset($_SESSION['xiangmu_exit_edit_form']);
		  db_delete('xiangmu_exit_info')
			->condition('id' ,$values['bid'])
			->execute();
		  db_update('xiangmu_info')
		 	->fields(array(
		   		'state' =>  1,
		   		))
			->condition('id', $values['bid'])
		  	->execute();	 
	  }

}
